Repository navigation
fix(agents): resume interrupted turns without a recognized abort string - #114121
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 10:59 AM ET / 14:59 UTC. ClawSweeper reviewWhat this changesThe PR changes gateway restart recovery so an assistant transcript tail marked Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this PR open for maintainer review: the patch is a focused repair to interrupted-session recovery and its targeted coverage is well aligned, but the supplied evidence is test/CI-only rather than direct after-fix restart evidence. The protected Priority: P2 Review scores
Verification
How this fits togetherWhen a gateway restarts, main-session recovery examines a persisted interrupted transcript and either resumes the agent or posts a resend notice. The changed classifier determines that branch, while downstream logic restricts unresolved tool calls before continuation. flowchart LR
A[Gateway restart] --> B[Persisted interrupted session]
B --> C[Transcript-tail classifier]
C --> D{Safe to resume?}
D -->|Yes| E[Recovery continuation]
E --> F[Dangling-tool safeguards]
D -->|No| G[Resend notice]
Decision needed
Why: The implementation changes persisted-session recovery semantics, and the available evidence is strong test coverage but not an observed after-fix gateway restart. The protected label requires explicit maintainer handling. Before merge
Agent review detailsSecurityNone. PR surfaceSource +10, Tests +29, Docs +6. Total +45 across 3 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the narrow Do we have a high-confidence way to reproduce the issue? No independent high-confidence live reproduction is included. The source and focused tests provide a clear reproducible path: persist a running session with an aborted assistant tail using a non-allowlisted worker/provider abort detail, then restart recovery should resume it under existing tool safeguards. Is this the best way to solve the issue? Unclear pending direct restart evidence. Treating AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2b7b0f244095. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Addressing the two rank-up moves before landing. Which shipped surfaces actually persist a non-allowlisted abort detail The strongest checkable answer to "does this matter at runtime?" is naming the
That adapter is production-wired through Why the runtime trace is a follow-up, not part of this PR The existing restart scenarios Producing the trace you're asking for needs a new QA scenario that restarts a What is proven here in the meantime: the three aborted-tail shapes (no abort |
|
Merged via squash.
|
What Problem This Solves
An ordinary gateway restart could leave a main session showing the terminal
notice instead of resuming:
Restart recovery classifies the transcript tail before resuming. An interrupted
turn is persisted as an assistant message with
stopReason: "aborted", butisRestartAbortAssistantMessageinsrc/agents/main-session-restart-recovery-resume-policy.tsadditionally requirederrorMessageto be one of three exact strings:Request was abortedThis operation was abortedagent run aborted for restartProduction writes several other abort details on that same tail. The worker
inference adapter persists
Worker inference aborted.andWorker inference aborted before start.(
src/worker/inference-stream.runtime.ts:246,:262), andterminalErrorMessagecopies whatever cancel message the transport reported(
src/worker/inference-stream.runtime.ts:195). A tail carrying any of those fellthrough every resume branch to
transcript tail is not resumable, so the userwas asked to re-send a request the gateway could have continued on its own.
Why This Change Was Made
Every row that reaches
recoverStorewas mid-run when the process went down:mark_interruptedis dispatched only from the restart/startup-orphan paths insrc/agents/main-session-restart-recovery-marking.ts, and the entry must still berunningwithabortedLastRun === true. In that contextstopReason: "aborted"is the interruption, so matching on the abort string was a leaky proxy for a
fact the stop reason already carries.
isRestartAbortAssistantMessagenow treats anyabortedtail as the restartabort and keeps the allowlist for
stopReason: "error", where the error may be agenuine provider failure rather than lifecycle noise.
The safety machinery downstream is unchanged and does the real work:
classifyDanglingToolCalls, so anything outside the audited replay-safeallowlist resumes with
forceRestartSafeTools; the continuation can inspectand report, never silently re-execute an ambiguous side effect.
decides resume safety.
before_agent_replyoutcomes, unknown terminal delivery outcomes,stale approval-pending tails, missing message-tool authority, and empty
transcripts all still fail closed with the notice.
User Impact
A gateway restart during a turn now resumes best-effort in the common case
instead of asking the user to send the request again. Side-effect safety is
unchanged: ambiguous tool calls resume restricted to restart-safe tools, and
genuinely unsafe tails still get the notice.
docs/gateway/restart-recovery.mddescribes the aborted-tail behavior andnarrows the "unsafe tail" example to a provider failure or stale approval.
Evidence
node scripts/run-vitest.mjs src/agents/main-session-restart-recovery.test.ts— 137 passed. Adds a table covering aborted tails persisted with no abort
string, with a worker abort string, and with a dangling side-effecting call
(asserting
forceRestartSafeTools); removes the two aborted rows from the"does not resume" table that encoded the old behavior.
node scripts/run-vitest.mjs src/agents/main-session-recovery-state.test.ts src/agents/main-session-recovery-store.test.ts src/agents/agent-command-restart-recovery.test.ts src/agents/agent-command-recovery-owner.test.ts— 97 passed.
node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat-b.test.ts— 89 passed.
node scripts/check-changed.mjs— exit 0 (delegated to Blacksmith Testboxtbx_01kyfec215qvz6tvh7ce6hbyqw, 5m12s).gpt-5.6-sol, xhigh): clean, no accepted/actionablefindings.
Three notice-delivery tests used an aborted tail purely as a convenient
"unresumable" fixture; they now use a shared
unresumableAssistantMessage()provider-failure shape so they keep proving notice mechanics rather than resume
classification.