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:
parent
5188027d8b
commit
978af45d5f
@ -473,13 +473,18 @@ async fn agent_loop(
|
|||||||
|
|
||||||
// Prepare state for execution: set first pending step to Running
|
// Prepare state for execution: set first pending step to Running
|
||||||
if let Some(next) = state.first_actionable_step() {
|
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 let Some(step) = state.steps.iter_mut().find(|s| s.order == next) {
|
||||||
if matches!(step.status, StepStatus::Pending) {
|
if matches!(step.status, StepStatus::Pending) {
|
||||||
step.status = StepStatus::Running;
|
step.status = StepStatus::Running;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.phase = AgentPhase::Executing { step: next };
|
state.phase = AgentPhase::Executing { step: next };
|
||||||
state.current_step_chat_history.clear();
|
// 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;
|
let instructions = read_instructions(&workdir).await;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user