huskies: merge 652_story_pass_resume_session_id_on_agent_respawn_so_new_sessions_inherit_prior_reasoning

This commit is contained in:
dave
2026-04-27 11:23:28 +00:00
parent 144f07f412
commit ac85cfce5d
8 changed files with 319 additions and 10 deletions
+40 -6
View File
@@ -7,6 +7,7 @@ use tokio::sync::broadcast;
use crate::agent_log::AgentLogWriter;
use crate::io::watcher::WatcherEvent;
use crate::slog_warn;
use super::{AgentEvent, AgentRuntime, RuntimeContext, RuntimeResult, RuntimeStatus};
@@ -49,18 +50,51 @@ impl AgentRuntime for ClaudeCodeRuntime {
&ctx.cwd,
&tx,
&event_log,
log_writer,
log_writer.clone(),
ctx.inactivity_timeout_secs,
Arc::clone(&self.child_killers),
self.watcher_tx.clone(),
ctx.session_id_to_resume.as_deref(),
)
.await?;
.await;
Ok(RuntimeResult {
session_id: pty_result.session_id,
token_usage: pty_result.token_usage,
})
match pty_result {
Ok(result) => Ok(RuntimeResult {
session_id: result.session_id,
token_usage: result.token_usage,
}),
Err(e) if ctx.session_id_to_resume.is_some() && ctx.fresh_prompt.is_some() => {
// Resume failed — fall back to a fresh session without --resume.
slog_warn!(
"[agents] Resume failed for {}:{}, retrying without --resume: {}",
ctx.story_id,
ctx.agent_name,
e
);
let fresh = ctx.fresh_prompt.unwrap();
let fallback_result = super::super::pty::run_agent_pty_streaming(
&ctx.story_id,
&ctx.agent_name,
&ctx.command,
&ctx.args,
&fresh,
&ctx.cwd,
&tx,
&event_log,
log_writer,
ctx.inactivity_timeout_secs,
Arc::clone(&self.child_killers),
self.watcher_tx.clone(),
None, // no --resume on fallback
)
.await?;
Ok(RuntimeResult {
session_id: fallback_result.session_id,
token_usage: fallback_result.token_usage,
})
}
Err(e) => Err(e),
}
}
fn stop(&self) {