mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-10 18:14:50 +08:00
feat(session): persist model in session metadata — ROADMAP #59
Add 'model: Option<String>' to Session struct. The model used is now
saved in the session_meta JSONL record and surfaced in resumed /status:
- JSON mode: {model: 'claude-sonnet-4-6'} instead of null
- Text mode: shows actual model instead of 'restored-session'
Model is set in build_runtime_with_plugin_state() before the runtime
is constructed, and only when not already set (preserves model through
fork/resume cycles).
Backward compatible: old sessions without a model field load cleanly
with model: None (shown as null in JSON, 'restored-session' in text).
All workspace tests pass.
This commit is contained in:
@@ -2789,7 +2789,7 @@ fn run_resume_command(
|
||||
Ok(ResumeCommandOutcome {
|
||||
session: session.clone(),
|
||||
message: Some(format_status_report(
|
||||
"restored-session",
|
||||
session.model.as_deref().unwrap_or("restored-session"),
|
||||
StatusUsage {
|
||||
message_count: session.messages.len(),
|
||||
turns: tracker.turns(),
|
||||
@@ -2801,7 +2801,7 @@ fn run_resume_command(
|
||||
&context,
|
||||
)),
|
||||
json: Some(status_json_value(
|
||||
None,
|
||||
session.model.as_deref(),
|
||||
StatusUsage {
|
||||
message_count: session.messages.len(),
|
||||
turns: tracker.turns(),
|
||||
@@ -6752,7 +6752,7 @@ fn build_runtime(
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn build_runtime_with_plugin_state(
|
||||
session: Session,
|
||||
mut session: Session,
|
||||
session_id: &str,
|
||||
model: String,
|
||||
system_prompt: Vec<String>,
|
||||
@@ -6763,6 +6763,10 @@ fn build_runtime_with_plugin_state(
|
||||
progress_reporter: Option<InternalPromptProgressReporter>,
|
||||
runtime_plugin_state: RuntimePluginState,
|
||||
) -> Result<BuiltRuntime, Box<dyn std::error::Error>> {
|
||||
// Persist the model in session metadata so resumed sessions can report it.
|
||||
if session.model.is_none() {
|
||||
session.model = Some(model.clone());
|
||||
}
|
||||
let RuntimePluginState {
|
||||
feature_config,
|
||||
tool_registry,
|
||||
|
||||
Reference in New Issue
Block a user