fix(runner): keep stopped provider checkpoint closed

This commit is contained in:
Dotta 2026-09-03 05:27:04 -05:00
parent a55b6e6409
commit 65c204f060
3 changed files with 10 additions and 3 deletions

View File

@ -971,7 +971,11 @@ impl AcpxCommandExecutor {
.as_mut()
.expect("ACPX state remains available after provider termination");
state.active_turn_id = None;
state.lifecycle = "suspended".to_owned();
// Keep the provider checkpoint closed while runnerd drains the
// already-persisted event suffix. `suspended` is a recoverable ACPX
// lifecycle and would make the following runner.drain command restart
// the provider generation that turn.stop just proved terminated.
state.lifecycle = "prepared".to_owned();
self.save_state()?;
Ok(CommandExecution::result(json!({
"status": "stopped",

View File

@ -2183,7 +2183,10 @@ impl CodexCommandExecutor {
state.active_provider_result_fingerprint = None;
state.active_provider_result_disposition = None;
state.last_agent_message = None;
state.lifecycle = "provider_exited".to_owned();
// Do not let the runner.drain command that follows turn.stop restore a
// fresh provider process. `prepared` retains the durable thread while
// deferring the only authorized restart to the successor run.attach.
state.lifecycle = "prepared".to_owned();
self.save_state()?;
Ok(CommandExecution::result(json!({
"status": "stopped",

View File

@ -2129,7 +2129,7 @@ it("persists an active provider as settled before bounded suspension", async ()
),
) as Record<string, unknown>;
expect(providerState).toMatchObject({
lifecycle: "provider_exited",
lifecycle: "prepared",
activeProviderTurnId: null,
});
} finally {