Repository navigation
fix(server): settle Claude background agents when their process exits - #19464
Exotic209093 wants to merge 2 commits into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused server bug fix that makes Claude background-agent cleanup consistent with process ownership and adds regression coverage for failure, cancellation, workflow, and buffered-result cases. The change is isolated to an existing adapter path with no schema, deployment, default, or static-analysis configuration impact. You can add or adjust custom eligibility rules. Learn more. |
|
I hit exactly this bug today. A main thread had launched several background Claude subagents, and one of them was running I traced it to the same |
A plain Claude background Agent can stay running forever when its CLI process exits after the parent turn has finished. Process-exit cleanup only settled workflow coordinators, leaving ordinary tasks without a terminal notification.
Apply the same process-owned cleanup to ordinary background agents: unexpected exits fail them, Stop cancels them, and buffered completion outcomes are preserved. Cleanup uses the exiting query's own last turn and retains the existing run and process ownership guards.
The restart recovery fixture now snapshots the legacy persisted state of a stopped provider session with an orphaned running task. It retains its original checks under both restart settings: recovery cancels the task, creates no automatic continuation, and delivers the cancellation note exactly once on the next user turn.
Validation: the idle-exit regression fails against the original production source and passes with the fix. All 255 Claude adapter tests pass, including plain agents, workflows, Stop, and buffered completion cases. The restart integration passes both cases independently. A combined focused adapter/integration run passes 260 tests. Scoped server typecheck, lint, formatting, and independent source review pass. No real provider, client, or service was launched.
Closes #19440. Related #18967 handles late notifications after replacement; this fix covers an idle process exit with no notification.
Linux CI on
3c390d7passes all 255 Claude adapter tests and both restart integration cases. All CI checks and CodeRabbit pass on that commit.Implemented with GPT-6.1-Sol through the Codex harness in T3 Code.