huskies: merge 543_story_resume_failed_coder_agents_with_resume_instead_of_starting_fresh_sessions

This commit is contained in:
dave
2026-04-12 12:52:46 +00:00
parent c80931c15c
commit 5f01631e6a
16 changed files with 135 additions and 52 deletions
+24 -5
View File
@@ -17,6 +17,7 @@ use super::super::{AgentPool, StoryAgent};
impl AgentPool {
/// Pipeline advancement: after an agent completes, move the story to
/// the next pipeline stage and start the appropriate agent.
#[allow(clippy::too_many_arguments)]
pub(super) async fn run_pipeline_advance(
&self,
story_id: &str,
@@ -25,6 +26,7 @@ impl AgentPool {
project_root: Option<PathBuf>,
worktree_path: Option<PathBuf>,
merge_failure_reported: bool,
previous_session_id: Option<String>,
) {
let project_root = match project_root {
Some(p) => p,
@@ -81,7 +83,7 @@ impl AgentPool {
if let Err(e) = crate::agents::lifecycle::move_story_to_qa(&project_root, story_id) {
slog_error!("[pipeline] Failed to move '{story_id}' to 3_qa/: {e}");
} else if let Err(e) = self
.start_agent(&project_root, story_id, Some("qa"), None)
.start_agent(&project_root, story_id, Some("qa"), None, None)
.await
{
slog_error!("[pipeline] Failed to start qa agent for '{story_id}': {e}");
@@ -118,7 +120,13 @@ impl AgentPool {
completion.gate_output
);
if let Err(e) = self
.start_agent(&project_root, story_id, Some(agent_name), Some(&context))
.start_agent(
&project_root,
story_id,
Some(agent_name),
Some(&context),
previous_session_id,
)
.await
{
slog_error!(
@@ -202,7 +210,7 @@ impl AgentPool {
coverage_output
);
if let Err(e) = self
.start_agent(&project_root, story_id, Some("qa"), Some(&context))
.start_agent(&project_root, story_id, Some("qa"), Some(&context), None)
.await
{
slog_error!("[pipeline] Failed to restart qa for '{story_id}': {e}");
@@ -223,7 +231,7 @@ impl AgentPool {
completion.gate_output
);
if let Err(e) = self
.start_agent(&project_root, story_id, Some("qa"), Some(&context))
.start_agent(&project_root, story_id, Some("qa"), Some(&context), None)
.await
{
slog_error!("[pipeline] Failed to restart qa for '{story_id}': {e}");
@@ -322,6 +330,7 @@ impl AgentPool {
story_id,
Some("mergemaster"),
Some(&context),
None,
)
.await
{
@@ -369,7 +378,7 @@ impl AgentPool {
return;
}
if let Err(e) = self
.start_agent(project_root, story_id, Some("mergemaster"), None)
.start_agent(project_root, story_id, Some("mergemaster"), None, None)
.await
{
slog_error!("[pipeline] Failed to start mergemaster for '{story_id}': {e}");
@@ -392,6 +401,7 @@ pub(super) fn spawn_pipeline_advance(
worktree_path: Option<PathBuf>,
watcher_tx: broadcast::Sender<WatcherEvent>,
merge_failure_reported: bool,
previous_session_id: Option<String>,
) {
let sid = story_id.to_string();
let aname = agent_name.to_string();
@@ -410,6 +420,7 @@ pub(super) fn spawn_pipeline_advance(
project_root,
worktree_path,
merge_failure_reported,
previous_session_id,
)
.await;
});
@@ -524,6 +535,7 @@ mod tests {
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -565,6 +577,7 @@ mod tests {
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -606,6 +619,7 @@ mod tests {
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -639,6 +653,7 @@ mod tests {
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -706,6 +721,7 @@ stage = "qa"
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -777,6 +793,7 @@ stage = "qa"
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -883,6 +900,7 @@ stage = "qa"
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -950,6 +968,7 @@ stage = "qa"
Some(root.to_path_buf()),
None,
false,
None,
)
.await;
@@ -83,6 +83,7 @@ impl AgentPool {
project_root_for_advance,
wt_path_for_advance,
merge_failure_reported_for_advance,
session_id_for_advance,
) = {
let mut agents = self.agents.lock().map_err(|e| e.to_string())?;
let agent = agents.get_mut(&key).ok_or_else(|| {
@@ -94,8 +95,9 @@ impl AgentPool {
let pr = agent.project_root.clone();
let wt = agent.worktree_info.as_ref().map(|w| w.path.clone());
let mfr = agent.merge_failure_reported;
let sid_advance = agent.session_id.clone();
agents.remove(&key);
(tx, sid, pr, wt, mfr)
(tx, sid, pr, wt, mfr, sid_advance)
};
// Emit Done so wait_for_agent unblocks.
@@ -128,6 +130,7 @@ impl AgentPool {
project_root_for_advance,
wt_path_for_advance,
merge_failure_reported_for_advance,
session_id_for_advance,
)
.await;
});
@@ -277,6 +280,8 @@ pub(in crate::agents::pool) async fn run_server_owned_completion(
lock.remove(&key);
(tx, pr, wt, mfr)
};
// The completed session's ID is used to resume if gates fail.
let previous_session_id = session_id.clone();
// Emit Done so wait_for_agent unblocks.
let _ = tx.send(AgentEvent::Done {
@@ -299,6 +304,7 @@ pub(in crate::agents::pool) async fn run_server_owned_completion(
wt_path_for_advance,
watcher_tx,
merge_failure_reported_for_advance,
previous_session_id,
);
}