Agent subagent results never delivered to parent in background job sessions

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 3 comments · opened Jul 6, 2026 · closed Aug 17, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Bug

When running Claude Code as a background job (spawned via the daemon), agents spawned with the Agent tool never deliver their completion results back to the parent session. The parent blocks indefinitely on run_in_background: false, or never receives a completion notification for background agents.

Reproduction

  1. Start Claude Code as a background job (via the daemon or desktop app)
  2. Enter a worktree (EnterWorktree)
  3. Spawn any agent — even a trivial one:

``
Agent({ prompt: "Say hello and nothing else.", run_in_background: false })
``

  1. The agent spawns, runs, completes (visible in the tmux swarm view), and goes idle
  2. The parent session never receives the result — it blocks forever

Observed behavior

  • The agent process starts and appears in ps aux and the tmux swarm view
  • The agent completes its work (verified by viewing its tmux pane)
  • An idle_notification teammate message is delivered to the parent, but the Agent tool's completion callback never fires
  • run_in_background: false blocks indefinitely
  • run_in_background: true (default) never sends a completion notification

Expected behavior

The Agent tool should return the agent's final text output to the parent session when the agent completes.

Environment

  • Claude Code v2.1.202
  • macOS (Darwin 25.5.0, arm64)
  • Running as a background job via the daemon
  • Inside a git worktree (.claude/worktrees/)
  • Tested with logic-reviewer, security-reviewer, test-reviewer, nitpick-reviewer, general-purpose, and default agent types — all exhibit the same behavior
  • Tested across two separate attempts (8+ agents total including a trivial "say hello" agent) in the same session

Impact

This blocks any multi-agent workflow from a background job session. Skill workflows that spawn reviewer subagents become non-functional — agents complete but results are lost.

Workaround

None found. The only option is to not use subagents from background job sessions.

View original on GitHub ↗

3 Comments

kcarriedo · 3 months ago

Confirmed -- background job + worktree + Agent tool is a bad combination right now. The idle_notification delivering but the completion callback never firing points at a message routing problem specific to the daemon/background path.

A few things that might help you unblock while this is open:

  1. If you can run interactively instead of as a background job, the completion callbacks work reliably. Not always possible, but worth mentioning.
  1. If you need background-job mode, you can work around the silent result loss by having each subagent write its output to a file (e.g. .claude/agent-results/{agent-name}.md) as its last action, then have the parent poll those files instead of waiting on the callback. Ugly, but it unblocks the workflow.
  1. The worktree isolation is probably relevant here -- the agent runs in a forked process tree rooted at the worktree path, and if the IPC channel back to the parent was established before the worktree was entered, it may be the wrong socket. Worth checking whether the issue reproduces outside a worktree.

The "tested with trivial 'say hello' agent" line in your report is the strongest evidence this is a routing/IPC bug rather than something in the agent logic itself. Good bug report.

bcherny collaborator · 1 month ago

Tried to reproduce this on 2.1.233 (Linux): dispatched a background job (claude --bg) in a fresh git repo with your exact steps — EnterWorktree, then a foreground Agent spawn that replies "hello", then print the reply. Ran it twice.

Both runs completed in under a minute: the job switched into its worktree, spawned the subagent, received the completion notification, printed The subagent's exact reply: hello, and finished. Nothing blocked or hung, so I couldn't reproduce the behavior you described.

Around the time this was filed, background-agent completion handling had several known problems that have since been fixed — see the changelog (e.g. background sessions silently stopping mid-turn, background subagents being cancelled during their startup window, tasks stuck on "Running" after finishing).

This looks fixed in a recent release. Closing — if you can still reproduce it on 2.1.233 or later, reply here with the version and the job transcript and we'll reopen.

🤖 Generated with Claude Code

github-actions[bot] · 8 days ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.