fix: comment on completed workflow resets to Planning phase with feedback
This commit is contained in:
parent
f70328be0b
commit
2cb9d9321e
16
src/agent.rs
16
src/agent.rs
@ -204,7 +204,7 @@ impl AgentManager {
|
||||
let mut initial_state = state_json
|
||||
.and_then(|json| serde_json::from_str::<crate::state::AgentState>(&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))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user