[BUG] (Async) Subagents stopping early

Open 💬 8 comments Opened Apr 14, 2026 by rudra-sett

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Subagents spawned via the Task tool with run_in_background: true can stop executing before completing their work, and the Claude Agent SDK reports them as <status>completed</status> to the parent agent. The parent has no reliable way to distinguish a subagent that finished successfully from one that was terminated prematurely.

I see subagents that:

  • Make anywhere from 5-40 tool calls over 2-10 minutes
  • Were still actively making tool calls when execution stopped (stop_reason: None on final messages)
  • Never reached the final step of their instructions (writing output to a file)
  • Were reported to the parent as <status>completed</status>

Essentially, the agent stopped mid-work, and the SDK told the parent it "completed."

This is a recurring pattern, seems to happen in about 14-30% of agent runs. I do not think this is a prompting issue because it always happens after some tool results - the subagent uses a tool, gets the result, and just stops without producing any output.

What Should Happen?

  1. The SDK should not report completed when a subagent was terminated before it chose to stop. The stop_reason: None on the subagent's final messages indicates the agent did not choose end_turn -- something external ended the session. The task notification should reflect this (e.g., <status>terminated</status> or <status>interrupted</status>).
  1. The task notification should include a stop_reason or termination_reason field so the parent agent can more easily determine what happened and decide whether to retry.

Error Messages/Logs

The task notification for the prematurely stopped subagent:

<task-notification>
<task-id>aaa583525301d9735</task-id>
<tool-use-id>toolu_011KhgSzp2v9Cd9iANWVUUYf</tool-use-id>
<output-file>/tmp/claude-1000/-home-user/tasks/aaa583525301d9735.output</output-file>
<status>completed</status>
<summary>Agent "Research TERN-501 and TERN-801" completed</summary>
<usage><total_tokens>64000</total_tokens><tool_uses>44</tool_uses><duration_ms>143711</duration_ms></usage>
</task-notification>

Compare to a subagent that actually finished its work (also reports completed, but includes a <result> block):

<task-notification>
<task-id>a9969619664ec9d75</task-id>
<tool-use-id>toolu_01HTpSYExfZarv9benv4oFAE</tool-use-id>
<output-file>/tmp/claude-1000/-home-user/tasks/a9969619664ec9d75.output</output-file>
<status>completed</status>
<summary>Agent "Research ORX142 and ORX489" completed</summary>
<result>
All 61 citations passed verification with zero errors and zero warnings. The research notes file is complete and verified.
The research findings have been written to `/home/user/working/research_notes/orexia_assets.md`.
</result>
</task-notification>

The only observable difference is the presence/absence of <result>. The <status> is identical in both cases.

Subagent's final messages before it stopped (from the subagent transcript research-assistant_aaa583525301d9735.jsonl):

The subagent's last three assistant messages all have stop_reason: None (not end_turn), and the agent was actively issuing tool calls:

[assistant] stop_reason: None
TEXT: "Let me read the S-1 for patent expiry details..."
[assistant] stop_reason: None  
TOOL: mcp__local__read_source(source_id: src189)
[assistant] stop_reason: None
TOOL: mcp__local__read_source(source_id: src185)

The agent never chose to stop. It was still working when execution ended.

Steps to Reproduce

  1. Create a parent agent th1at spawns a subagent via the Task tool with run_in_background: true.
  2. Give the subagent a prompt that requires many sequential tool calls before producing output. For example: "Search for and read 15 source documents about [topic], then write a comprehensive summary with citations to /home/user/working/research_notes/output.md."
  3. The subagent will begin actively researching (search, read, search, read...). At some point, execution stops.
  4. The parent receives a task notification with <status>completed</status> and no <result> block.
  5. The output file was never created. The parent discovers this only by checking the filesystem.

Note that it's a relatively transient issue, just one that causes a lot of waste.

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.104

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

_No response_

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗