[Bug] TaskOutput returns raw JSONL transcript instead of subagent summary (regression in 2.0.77)
Description
When using TaskOutput to retrieve results from a subagent, the tool result contains raw JSONL session transcript data instead of the subagent's actual findings/summary. This completely undermines the purpose of subagents, which is context isolation - the main agent now receives the full subagent conversation (including all tool inputs and outputs) in its context window.
This is a regression introduced in v2.0.77. Version 2.0.76 correctly returned a summarized format ([Tool: Name] {args} + --- RESULT --- with actual findings).
Related Issue
See #17208 which describes the same problem but was filed as a feature request. This is actually a regression from previously working behavior.
Environment
- Last working version: 2.0.76
- First broken version: 2.0.77
- OS: macOS
Reproduction Steps
claude --output-format stream-json --verbose --print \
"launch the Explore subagent in the background to summarize the code base. After 5 seconds check on its progress and tell me what it found with its first tool call" \
> /tmp/claude_subagent_test.jsonl
Then inspect the TaskOutput tool_result message in the JSONL output.
Expected Behavior (worked in 2.0.76)
The <output> section in the tool_result should contain a clean summary of the subagent's findings:
<retrieval_status>success</retrieval_status>
<task_id>af9675b</task_id>
<task_type>local_agent</task_type>
<status>completed</status>
<output>
[Tool: Bash] {"command":"ls -la","description":"List files"}
[Tool: Read] {"file_path":"/src/main.py"}
--- RESULT ---
## Codebase Summary
The codebase is a Python/FastAPI application with the following structure:
- src/: Main application code
- tests/: Test suites
...
</output>
Actual Behavior (broken since 2.0.77)
The <output> section contains the raw JSONL session transcript:
<retrieval_status>success</retrieval_status>
<task_id>af9675b</task_id>
<task_type>local_agent</task_type>
<status>completed</status>
<output>
[Truncated. Full output: /tmp/claude/-private-tmp/tasks/af9675b.output]
{"parentUuid":null,"isSidechain":true,"userType":"external","cwd":"/private/tmp",...,"message":{"role":"user","content":"Explore and summarize the codebase..."},...}
{"parentUuid":"...","message":{"model":"claude-haiku-4-5-20251001","role":"assistant","content":[{"type":"tool_use","id":"toolu_01...","name":"Bash","input":{"command":"ls -la /private/tmp"}}],...}
{"parentUuid":"...","message":{"role":"user","content":[{"tool_use_id":"toolu_01...","type":"tool_result","content":"total 4216\ndrwxrwxrwt 492 root..."}]},...}
...
</output>
The main agent receives:
- The subagent's initial prompt
- Every tool call the subagent made (Bash, Glob, etc.)
- The full output of every tool call (file listings, command outputs, etc.)
- All intermediate assistant messages
Impact
- Broken context isolation: The main agent sees 100% of subagent tokens, negating the primary benefit of subagents
- Unusable output: The main agent receives garbage (raw JSON with UUIDs, timestamps, token usage) instead of actionable findings
- Context explosion: With multiple
TaskOutputcalls, the main agent's context fills with redundant subagent transcripts
7 Comments
This issue has been affecting me as well.
Because of this bug, we run into this error in the
claude-agent-sdk-pythonwhen the agent tries to read the large content from the subagent's output:What version of the claude agents sdk are you running with "@anthropic-ai/claude-agent-sdk": "^0.2.5" I am not seeing this issue.
The key is prompting both the orchestrator and the agent.
the SubAgentStop hook does not return the full transcript by default. It returns whatever your prompt instructs it to return.
@peterjrichens in your original Issue are saying that Claude Code CLI didn't have this problem before? How did you setup the prompting between the main orchestrator agent and sub agent in order to return only the following output:
@markojak here are more detailed reproduction steps:
Additional findings from debugging
We encountered this same issue (#18351, closed as dup) while running parallel background subagents.
Root cause observation
On version 2.1.17, the
.outputfile for background agents is a symlink pointing to the agent's JSONL transcript:When TaskOutput reads this file, it follows the symlink and returns the entire JSONL transcript instead of a summary.
Our experience (#18351)
We ran 4-5 parallel background subagents for research tasks. Upon completion, ~900KB of JSONL data flooded the parent context, triggering compaction.
---
✍️ Author: Claude Code (DevContainer) with @carrotRakko
Note: This comment was written and submitted by an AI agent (Claude Code), with human review and approval.
This issue is still alive and well; I just had my session get compacted because it read a full task's transcript instead of only the final output.
I believe the issue has been somewhat mitigated, but not resolved:
We tried re-enabling async subagents after these mitigations, but the extra tokens polluting the main agent context roughly doubled $ cost in our eval suite vs sync subagents, which is not a problem we had on versions 2.0.x