[Bug] context: fork skill returns before background subagents finish in interactive mode
Bug Description
context: fork skill returns before its background subagents finish; their results go to the main session
Version: Claude Code 2.1.296, macOS (Darwin 25.6.0), interactive CLI session, auto permission mode.
What happens
A skill with context: fork (and background: false) whose body tells the forked agent to spawn
subagents and wait for their results:
- The forked agent spawns 2 subagents with the Agent tool in one message. Both launch as
background (requestShape: "background" in their .meta.json, spawnDepth: 2,
parentAgentId = the fork).
- The fork gets "Async agent launched successfully" for each, writes one line ("Both reviewers
running. Waiting for results."), and ends its turn.
- The Skill tool immediately returns
Skill "<name>" completed (forked execution). Result: Both reviewers running. Waiting for results. - ~15 s and ~80 s later, each child's
SubagentHandbackreport andtask-notificationare
delivered to the main conversation, not to the fork. The fork never resumes, so everything
after "wait for results" in the skill (aggregating, writing the report) never runs.
Expected
From https://code.claude.com/docs/en/sub-agents (section "Run subagents in foreground or background" /
nesting): "In interactive sessions, a subagent that launches background subagents waits for their
results before it finishes", with child results going to the launching subagent and only the
top-level subagent's summary reaching the user. That page says forked skills follow
"Run skills in a subagent" instead, but the skills page
(https://code.claude.com/docs/en/skills, "Run skills in a subagent") doesn't describe what happens
to a fork's own background children.
So either the fork should wait for its children (as documented for interactive subagents), or the
docs should say that a context: fork skill can't wait on subagents in interactive sessions, and
how to make it wait.
Minimal repro
~/.claude/agents/echo-child.md:
---
name: echo-child
description: test child
tools: Read
---
Read ~/.zshrc line 1 and reply with it.
~/.claude/skills/fork-parent/SKILL.md:
---
name: fork-parent
description: test fork that waits on children
context: fork
agent: general-purpose
model: sonnet
background: false
---
Spawn two echo-child subagents in one message. Wait for both results, then reply "BOTH: <a> | <b>".
Repro result (run 2026-10-13, Claude Code 2.1.296, fresh sessions in a scratch project holding the two files above)
Interactive (claude "/fork-parent" in a terminal, workspace trusted, auto permission mode):
- The Skill result shown in the main conversation was the fork's interim line:
fork-parent ⎿ Both children running. Wait for results.
- Status line:
Waiting for 2 background agents to finish; thenMessage from @echo-childtwice in the
main conversation, and the main model summarized the children's results itself.
BOTH: …never appeared.- Subagent
.meta.json: fork =general-purpose,requestShape: "foreground", model sonnet;
both echo-child = requestShape: "background", parentAgentId = the fork, spawnDepth: 1.
Headless (claude -p "/fork-parent", same project):
- Output:
BOTH: A: hello from child file | B: hello from child file— the fork waited. - Subagent
.meta.json: both echo-child =requestShape: "foreground".
So the difference is fork mode: interactive sessions run the fork's children in the background
(fork mode on, so "Claude can't ask for the foreground"), and the fork ends its turn before they
report, while the docs say an interactive launcher "waits for their results before it finishes".
Workaround
Run the orchestrating step headless (claude -p, where subagents run in the foreground when the
parent needs their results), or set CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 (forces all subagents
to the foreground everywhere).
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 2.1.296
- Feedback ID: 24a30155-e8e0-47e5-ac30-2a95c1c60eaa