fix(agents): mark interrupted sessions before restart#82772
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. The linked report plus PR body provide a concrete forced-restart reproduction, and current-main source shows recovery skips Real behavior proof Next step before merge Security Review detailsBest possible solution: Review and land this PR after maintainer approval and CI, keeping the linked issue open until the merge closes it. Do we have a high-confidence way to reproduce the issue? Yes. The linked report plus PR body provide a concrete forced-restart reproduction, and current-main source shows recovery skips Is this the best way to solve the issue? Yes. Marking known active main sessions at the restart boundary, then letting existing startup recovery consume that marker, is a narrow fix that avoids broadening recovery to subagent, cron, ACP, or detached background-task sessions. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3b2cd0dd1a85. |
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
* fix(agents): mark interrupted sessions before restart * docs: add restart recovery changelog * fix(agents): satisfy restart recovery type checks
Summary
runningwithoutabortedLastRun, so startup recovery did not resume or fail the interrupted turn.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
Behavior addressed: forced gateway restart while a main agent turn is active leaves the session recoverable instead of stranded without
abortedLastRun.Real environment tested: AWS Crabbox, provider
aws, leasecbx_12b1656eac41, runrun_0c7d40c7e54e, Linux c7a.8xlarge, Node 22.22.2 bootstrapped in the run.Exact steps or command run after this patch: synced the patched dirty branch to Crabbox, built OpenClaw, started a gateway with isolated state and a local slow OpenAI-compatible model endpoint, began a main
agentcall, changed config to trigger a restart withgateway.reload.deferralTimeoutMs=1200, then inspected the persisted session row after the forced restart marker.Evidence after fix: run
run_0c7d40c7e54eprintedbefore_restart status=running abortedLastRun=false hasActiveRun=null, thenafter_restart status=running abortedLastRun=true hasActiveRun=null, plus[main-session-restart-recovery] marked 1 interrupted main session(s) for restart recovery (config reload forced restart).Observed result after fix: the harness printed
FIX_CONFIRMED issue=82433 active session marked restart-abortedand exited 0.What was not tested: actual provider auth and channel delivery were not exercised; the model endpoint was a local OpenAI-compatible slow-response server to isolate restart/session behavior.
Before evidence: AWS Crabbox main-branch repro
cbx_3da5ccc6840a, runrun_206ed4b243f8, showedafter_restart status=running abortedLastRun=false hasActiveRun=null.Root Cause (if applicable)
abortedLastRun.Regression Test Plan (if applicable)
src/agents/main-session-restart-recovery.test.ts,src/gateway/server-reload-handlers.test.ts,src/cli/gateway-cli/run-loop.test.tsUser-visible / Behavior Changes
Interrupted main agent sessions are now marked for restart recovery when a forced gateway restart cuts off active model/tool work.
Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
OPENCLAW_STATE_DIR, customsession.store,gateway.reload.mode=restart,gateway.reload.deferralTimeoutMs=1200Steps
agentrequest and wait for the session row to becomerunning.Expected
abortedLastRun=trueafter the forced restart marker.Actual
status=running abortedLastRun=true; harness exited 0.Evidence
Human Verification (required)
What you personally verified (not just CI), and how:
$codex-review, and AWS Crabbox before/after repro path for Gateway restart timeout can interrupt active agent work without marking sessions for continuation #82433.Review Conversations
Compatibility / Migration
Risks and Mitigations