[Bug] TaskOutput returns raw JSONL transcript instead of subagent summary (regression in 2.0.77)

Status Open
Reported on v2.0.76
Maintainer reply None cached
Activity 7 comments · opened Jan 12, 2026

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

  1. Broken context isolation: The main agent sees 100% of subagent tokens, negating the primary benefit of subagents
  2. Unusable output: The main agent receives garbage (raw JSON with UUIDs, timestamps, token usage) instead of actionable findings
  3. Context explosion: With multiple TaskOutput calls, the main agent's context fills with redundant subagent transcripts

View original on GitHub ↗

7 Comments

smithla02 · 7 months ago

This issue has been affecting me as well.

Because of this bug, we run into this error in the claude-agent-sdk-python when the agent tries to read the large content from the subagent's output:

Fatal error in message reader: Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes..
markojak · 7 months ago
This issue has been affecting me as well. Because of this bug, we run into this error in the claude-agent-sdk-python when the agent tries to read the large content from the subagent's output: `` Fatal error in message reader: Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes.. ``

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.

markojak · 7 months ago

@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:

<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>
peterjrichens · 7 months ago

@markojak here are more detailed reproduction steps:

Step 1: Test with working version (2.0.76)

  # Create test directory and install working version
  mkdir -p /tmp/claude-test-working && cd /tmp/claude-test-working
  npm init -y
  npm install @anthropic-ai/claude-code@2.0.76

  # Verify version
  ./node_modules/.bin/claude --version
  # Expected: 2.0.76 (Claude Code)

  # Run subagent test
  echo "Use the Task tool to spawn a Bash subagent in background to run 'ls -la'. Then use TaskOutput to get the result." \
    | ./node_modules/.bin/claude --output-format stream-json --verbose --print --dangerously-skip-permissions \
    > output.jsonl 2>&1

  # Extract TaskOutput result
  cat output.jsonl | jq -r 'select(.type=="user") | .message.content[]? | select(.type=="tool_result") | .content' | grep -A 100 "<output>"

  Expected output (CORRECT):
  <output>
  [Tool: Bash] {"command":"ls -la","description":"List all files with details"}

  --- RESULT ---
  The `ls -la` command was executed successfully...
  </output>

  Step 2: Test with broken version (2.1.1)

  # Create test directory and install broken version
  mkdir -p /tmp/claude-test-broken && cd /tmp/claude-test-broken
  npm init -y
  npm install @anthropic-ai/claude-code@2.1.1

  # Verify version
  ./node_modules/.bin/claude --version
  # Expected: 2.1.1 (Claude Code)

  # Run same subagent test
  echo "Use the Task tool to spawn a Bash subagent in background to run 'ls -la'. Then use TaskOutput to get the result." \
    | ./node_modules/.bin/claude --output-format stream-json --verbose --print --dangerously-skip-permissions \
    > output.jsonl 2>&1

  # Extract TaskOutput result
  cat output.jsonl | jq -r 'select(.type=="user") | .message.content[]? | select(.type=="tool_result") | .content' | grep -A 100 "<output>"

  Expected output (BUG - raw JSONL):
  <output>
  {"parentUuid":null,"isSidechain":true,"userType":"external","cwd":"/private/tmp/claude-test-broken","sessionId":"...","version":"2.1.1",...}
  {"parentUuid":"...","isSidechain":true,...,"message":{"content":[{"type":"tool_use","name":"Bash",...}]},...}
  ...
  </output>
carrotRakko · 7 months ago

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 .output file for background agents is a symlink pointing to the agent's JSONL transcript:

$ ls -la /tmp/claude/-workspaces/tasks/
lrwxrwxrwx ... a3d761c.output -> /home/.../.claude/projects/.../subagents/agent-a3d761c.jsonl

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.

asermax · 6 months ago

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.

peterjrichens · 6 months ago

I believe the issue has been somewhat mitigated, but not resolved:

  • the TaskOutput response is now truncated, so there's still a bunch of raw subagent jsonl leaking into the main agent context window, but not as much as before
  • there is also an (undocumented?) env var which allows you control the level of truncation: TASK_MAX_OUTPUT_LENGTH (defaults to 30,000 characters)
  • version 2.1.47 claims to have "Fixed background agent results returning raw transcript data instead of the agent's final answer". the jsonl is indeed replaced after the subagent has completed, but this has limited impact since TaskOutput is more typically called before the subagent completes, and there is no change in behaviour in this scenario

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