diff --git a/src/agent.rs b/src/agent.rs index b6bf3d7..9362f4d 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -473,13 +473,18 @@ 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 }; - 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;