fix: preserve step chat history when resuming after wait_for_approval
Previously, current_step_chat_history was cleared unconditionally on resume, causing the agent to lose context and re-run the step from scratch after approval. Now only clear when advancing to a new step.
This commit is contained in:
@@ -473,14 +473,19 @@ async fn agent_loop(
|
||||
|
||||
// Prepare state for execution: set first pending step to Running
|
||||
if let Some(next) = state.first_actionable_step() {
|
||||
let was_same_step = matches!(state.phase, AgentPhase::Executing { step } if step == next);
|
||||
if let Some(step) = state.steps.iter_mut().find(|s| s.order == next) {
|
||||
if matches!(step.status, StepStatus::Pending) {
|
||||
step.status = StepStatus::Running;
|
||||
}
|
||||
}
|
||||
state.phase = AgentPhase::Executing { step: next };
|
||||
// Only clear chat history when advancing to a new step;
|
||||
// keep it when resuming the same step after wait_for_approval
|
||||
if !was_same_step {
|
||||
state.current_step_chat_history.clear();
|
||||
}
|
||||
}
|
||||
|
||||
let instructions = read_instructions(&workdir).await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user