/code-review fork is finalized while its named finder agents still run under CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS
Bug Description
/code-review at medium effort and above runs as a background fork that fans out named finder subagents via the Agent tool. When CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 is set, the fork never receives its finders' completions, is finalized as "completed" while they still run, and their results are delivered to the top-level session minutes later as truncated teammate idle_notification messages. The skill's dedup and verify phases never run, so the review produces no findings.
Environment
- Claude Code 2.1.269 (Linux, native binary), model
claude-fable-5-1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1set in the project's.claude/settings.jsonenvblock- Interactive session (a background
&job in the daemon). Not-pmode, where subagents are synchronous.
Steps to reproduce
- In a repo with
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1in settingsenv, run/code-review high <range>on a multi-file diff (~2,600 lines here). - The Skill tool reports
Skill "code-review" launched (forked execution, running in the background). - Watch
ListAgents: the fork appears under Subagents; the eightfinderA…finderConventionsagents it spawned appear under Teammates with "not messageable by name while a subagent in this session is registered under that name". - Wait for the fork's task notification.
Expected
The fork stays alive until its finders report, dedups, dispatches verifiers, and returns the findings JSON.
Actual
- The fork's transcript shows eight
Agentcalls withnameset, six minutes of its own reading, then anend_turnsaying it will wait for finder notifications. It received zero notifications, although the first finder had already completed 1m49s before that end_turn. - The parent got the fork's
<task-notification>withstatus: completedand the note "fires each time this agent stops with no live background children of its own" — while eight children were still running. - Over the next ~30 minutes the parent received eight
<teammate-message>blocks with"result":"[result truncated — this drain's results exceeded 16000 characters; ask the agent for it via SendMessage]".SendMessageto those names is refused because the name "reaches the subagent". - Cost: ~155k tokens in the coordinator plus eight finders, with no review output.
Analysis
Under agent teams, an Agent spawned with name is registered as a session-wide teammate rather than as a child of the spawning fork. The fork's liveness check ("no live background children") therefore passes as soon as its turn ends, and the children's completions route to the session root. The built-in skill always passes name to its finders, so this reproduces on every medium-or-higher review in any repo with the flag on.
Suggested fix
Any one of:
- Count named spawns as children of the spawning fork in the liveness check and route their completions to it.
- Have the code-review skill spawn finders without
name(nothing in the skill messages them). - Ship the built-in skill with
background: falseforcontext: fork, which the frontmatter already supports.
Related: #89249 covers the cost of the same fan-out but not this failure.