From 2cb9d9321eddb8d8e7831f7644433a135bc24d8a Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Mon, 6 Apr 2026 22:56:35 +0100 Subject: [PATCH] fix: comment on completed workflow resets to Planning phase with feedback --- src/agent.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/agent.rs b/src/agent.rs index 17c157e..805e785 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -204,7 +204,7 @@ impl AgentManager { let mut initial_state = state_json .and_then(|json| serde_json::from_str::(&json).ok()); - // Attach comment as user feedback + reset failed/waiting steps + // Prepare state for re-execution with user feedback if let Some(ref mut state) = initial_state { for step in &mut state.steps { if matches!(step.status, crate::state::StepStatus::Failed) { @@ -214,10 +214,20 @@ impl AgentManager { step.status = crate::state::StepStatus::Running; } } - if let Some(order) = state.first_actionable_step() { + + if state.first_actionable_step().is_some() { + // Has pending/failed steps — attach feedback and resume + let order = state.first_actionable_step().unwrap(); if let Some(step) = state.steps.iter_mut().find(|s| s.order == order) { - step.user_feedbacks.push(content); + step.user_feedbacks.push(content.clone()); } + } else { + // All steps done — go back to Planning with user feedback + state.phase = crate::state::AgentPhase::Planning; + state.current_step_chat_history.clear(); + state.current_step_chat_history.push( + crate::llm::ChatMessage::user(&format!("【用户反馈】{}", content)) + ); } }