Skip to content

fix(agents): a Claude Code turn whose background subagents the CLI stopped fails - #783

Closed
victorlee-scale wants to merge 1 commit into
mainfrom
victorlee/claude-code-lost-background-subagents
Closed

victorlee-scale wants to merge 1 commit into
mainfrom
victorlee/claude-code-lost-background-subagents

Conversation

@victorlee-scale

@victorlee-scale victorlee-scale commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

In print mode the Claude Code CLI waits only CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS (10 minutes by default) after its last turn for background subagents. It then stops those still running, says so only on stderr, and exits 0. The bridge took the earlier result as the turn's answer, so a run whose subagents' work was lost was recorded as a success and graded (FD-5844).

The bridge now fails such a turn with claude CLI stopped background subagents before they finished: <descriptions>, reported as a cli_error. Only subagents (task_type: local_agent) count. A subagent that completed or failed, or that the agent stopped itself with TaskStop, doesn't, and neither do background shell commands, workflows or remote agents. Healthy turns are unchanged, and the wait ceiling itself is left as it is.

Validation: the new unit tests use event shapes from a capture of the pinned CLI (2.1.322), and the stopped-subagent test fails without the change. tst/unit/agents/claude_code passes (279 passed, 30 skipped). Not run against a live image.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

The bridge now fails turns that leave unfinished background subagents instead of accepting the CLI's successful exit.

  • Claude Code turns fail when background subagents are left unfinished.

No actionable issues found.

Reviews (1) · Last reviewed commit: "fix(agents): a Claude Code turn whose ba..." · Reviewed by Greptile

…opped fails

In print mode the CLI waits only so long after its last turn for background
subagents, then stops those still running, says so on stderr alone, and
exits 0. The bridge took the earlier result as the turn's answer, so a run
that lost its subagents' work was recorded as a success. The bridge now
fails such a turn with the subagents' descriptions. Subagents that finished
or failed, ones the agent stopped itself with TaskStop, and background tasks
other than subagents (task_type local_agent) don't count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@victorlee-scale
victorlee-scale requested a review from a team as a code owner November 18, 2026 18:44
@victorlee-scale
victorlee-scale marked this pull request as draft November 18, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant