[Bug] Subagent outputs include verbose API metadata causing session slowdown

Resolved 💬 4 comments Opened Jan 21, 2026 by yulonglin Closed Feb 28, 2026

Bug Description
Title: Subagent outputs return verbose JSONL/API metadata, causing session slowdown

Description:

Over the past week, I've noticed that subagent task outputs are returning extremely long JSON payloads that include internal API response metadata (e.g., cache_creation_input_tokens, requestId, uuid, raw message content from cached prompts). This causes sessions to slow to a crawl.

Example excerpt from output:

...cache_creation":{"ephemeral_5m_input_tokens":341,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard"}},"requestId":"req_011CXMBqABLqGvmP19g5mGjF"...

This might be related to #16789 - subagents should return only the final result text, not the full JSONL conversation log with API metadata.

MCP servers: gitmcp, context7, GitHub, custom Slack MCP

Expected behavior: Subagent outputs should be summarized/truncated to just the relevant result, not raw API response payloads.

Workaround: Unclear

Environment Info

  • Platform: darwin, macOS Tahoe 26.2
  • Terminal: ghostty
  • Version: 2.1.14
  • Feedback ID: 035f34af-b877-4f0a-b6b2-bb2d3ae57ef7

Errors

.../password_wrapper_solver.py - Pattern to follow for solver
    structure"}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":1,"cache_creation_input_tokens":341,"cache_read_input_tokens":100526,"cache_creation":{"ephemeral_5m_i
    nput_tokens":341,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard"}},"requestId":"req_011CXMBqABLqGvmP19g5mGjF","type":"assistant","uuid":"ec57f34f-1878-4
    1ac-82be-c2bd61ee3a76","timestamp":"2026-01-21T20:54:39.874Z"}
  ⎿  Running PostToolUse hook…
       · PostToolUse:TaskOutput: python3 ${CLAUDE_PLUGIN_ROOT}/hooks/posttooluse.py
[{"error":"Error: ENOENT: no such file or directory, scandir '/Library/Application Support/ClaudeCode/.claude/skills'\n    at readdirSync (unknown)\n    at <anonymous> (/$bunfs/root/claude:12:1903)\n    at e3 (/$bunfs/root/claude:11:34695)\n    at readdirSync (/$bunfs/root/claude:12:1864)\n    at n6R (/$bunfs/root/claude:1465:380)\n    at n6R (/$bunfs/root/claude:1465:1350)\n    at <anonymous> (/$bunfs/root/claude:1465:4440)\n    at <anonymous> (/$bunfs/root/claude:1465:5171)\n    at A (/$bunfs/root/claude:11:7245)\n    at zC8 (/$bunfs/root/claude:4096:4342)","timestamp":"2026-01-21T21:18:00.530Z"},{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/yulong/.local/share/claude/versions/2.1.14 (expected in multi-process scenarios)\n    at wZR (/$bunfs/root/claude:3215:2091)\n    at JFA (/$bunfs/root/claude:3215:1202)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-01-21T21:18:00.618Z"},{"error":"Error: ENOENT: no such file or directory, scandir '/Library/Application Support/ClaudeCode/.claude/skills'\n    at readdirSync (unknown)\n    at <anonymous> (/$bunfs/root/claude:12:1903)\n    at e3 (/$bunfs/root/claude:11:34695)\n    at readdirSync (/$bunfs/root/claude:12:1864)\n    at n6R (/$bunfs/root/claude:1465:380)\n    at n6R (/$bunfs/root/claude:1465:1350)\n    at <anonymous> (/$bunfs/root/claude:1465:4440)\n    at <anonymous> (/$bunfs/root/claude:1465:5171)\n    at A (/$bunfs/root/claude:11:7245)\n    at zC8 (/$bunfs/root/claude:4096:4342)","timestamp":"2026-01-21T21:18:07.113Z"},{"error":"Error: Tool mcp__gitmcp__search_generic_code not found\n    at A6B (/$bunfs/root/claude:2528:6640)\n    at AC (/$bunfs/root/claude:525:20764)\n    at cC (/$bunfs/root/claude:525:39157)\n    at Zb (/$bunfs/root/claude:525:49777)\n    at xM (/$bunfs/root/claude:525:86047)\n    at Is (/$bunfs/root/claude:525:85021)\n    at jm (/$bunfs/root/claude:525:84846)\n    at ym (/$bunfs/root/claude:525:81269)\n    at CA (/$bunfs/root/claude:525:6275)\n    at gsR (/$bunfs/root/claude:518:15223)","timestamp":"2026-01-21T21:18:45.180Z"},{"error":"Error: Tool mcp__gitmcp__search_generic_documentation not found\n    at A6B (/$bunfs/root/claude:2528:6640)\n    at AC (/$bunfs/root/claude:525:20764)\n    at cC (/$bunfs/root/claude:525:39157)\n    at Zb (/$bunfs/root/claude:525:49777)\n    at xM (/$bunfs/root/claude:525:86047)\n    at Is (/$bunfs/root/claude:525:85021)\n    at jm (/$bunfs/root/claude:525:84846)\n    at ym (/$bunfs/root/claude:525:81269)\n    at CA (/$bunfs/root/claude:525:6275)\n    at gsR (/$bunfs/root/claude:518:15223)","timestamp":"2026-01-21T21:18:45.181Z"},{"error":"Error: 1P event logging: 2 events failed to export\n    at queueFailedEvents (/$bunfs/root/claude:620:2077)\n    at async doExport (/$bunfs/root/claude:620:1257)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-01-21T21:19:02.319Z"},{"error":"Error: {\"message\":\"Failed to export 2 events\",\"originalLine\":\"620\",\"originalColumn\":\"1336\",\"line\":\"620\",\"column\":\"1336\",\"sourceURL\":\"/$bunfs/root/claude\",\"stack\":\"Error: Failed to export 2 events\\n    at doExport (/$bunfs/root/claude:620:1336)\\n    at processTicksAndRejections (native:7:39)\",\"name\":\"Error\"}\n    at error (/$bunfs/root/claude:2249:25028)\n    at <anonymous> (/$bunfs/root/claude:614:36349)\n    at PzD (/$bunfs/root/claude:614:36893)\n    at <anonymous> (/$bunfs/root/claude:615:17366)\n    at…

Note: Content was truncated.

---

UPDATE: Gemini 3 Pro's summary of another instance of this issue

Context: In planning mode, the agent spun out an Explore agent to explore parts of the codebase, when this happened. It once against slows to a crawl when this happens. CPU usage is low (~50% total on system).

Here is a summary and curated snippets formatted for a bug report or issue ticket. This log captures a subagent (hazy-singing-sunbeam) performing a massive context-loading operation that results in high latency ("Bloviating... 4m 6s") and excessive token usage (~108k tokens).

Issue Summary

Title: Subagent loads excessive context (~100k+ tokens) and enters long generation loop ("Bloviating") for exploration tasks.

Description:
When spinning up a subagent to explore a workflow (specifically "embedding entropy"), the agent systematically reads the entire contents of multiple large Python source files and configuration files rather than searching or reading relevant snippets.

This results in:

  1. Context Explosion: Cache read tokens spike from ~500 to 108,206 within a single session.
  2. High Latency: The final response generation takes over 4 minutes (indicated by the TUI status "Bloviating... 4m 6s").
  3. Inefficiency: The agent reads 1,600+ line files (e.g., run_consistency_classifier.py) in their entirety multiple times via the Read tool.

---

Log Analysis & Key Events

1. Initial State
  • Agent: hazy-singing-sunbeam
  • Model: claude-haiku-4-5-20251001
  • Initial Context: Low (~500 tokens)
2. The Context Loading Loop (The "Over-fetch")

The agent executes a series of Read tool calls on large files, dumping the entire file content into the context window.

  • Reads entire CLI entry point: src/detection_game/cli/run_sweep.py
  • Reads entire Classifier logic: src/detection_game/classifiers/run_consistency_classifier.py (Lines 1-1683 dumped).
  • Reads entire CV logic: src/detection_game/classifiers/run_multisample_bootstrap_cv.py (Lines 1-1325 dumped).
  • Reads massive config lists: Multiple find and grep commands returning huge file lists.
3. The Token Spike

The token usage metrics show a rapid escalation:

  • Timestamp 03:18:20: 27,087 cache tokens.
  • Timestamp 03:18:37: 90,783 cache tokens.
  • Timestamp 03:19:43: 108,206 cache tokens.
4. The "Bloviation" (Final Output)

At the end of the trace, the agent decides it has "enough information" and generates a massive, multi-page Markdown report in a single message turn.

  • TUI Status: ✻ Bloviating… (esc to interrupt · 4m 6s · ↓ 1.7k tokens · thought for 3s)
  • Result: A monolithic response detailing the entire experimental pipeline, configuration parameters, and CLI commands.

---

Relevant Log Snippets (For the Report)

Snippet 1: Reading massive files (Source of context explosion)

{
  "type": "tool_use",
  "name": "Read",
  "input": {
    "file_path": "/home/yulong/code/sandbagging-detection/dev/src/detection_game/classifiers/run_consistency_classifier.py"
  }
}
// ... followed by tool_result containing lines 1 through 1683 ...

Snippet 2: Token usage metrics hitting 100k+

{
  "model": "claude-haiku-4-5-20251001",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Perfect! Now I have all the information I need. Let me provide a comprehensive analysis..."
    }
  ],
  "usage": {
    "input_tokens": 7,
    "cache_creation_input_tokens": 4720,
    "cache_read_input_tokens": 108206, 
    "output_tokens": 1
  },
  "timestamp": "2026-01-23T03:20:58.469Z"
}

Snippet 3: TUI indicating long generation time

PostToolUse:TaskOutput hook succeeded: Success                                                                                                            
✻ Bloviating… (esc to interrupt · 4m 6s · ↓ 1.7k tokens · thought for 3s)

Recommendation for Fix

The subagent should be prompted or configured to:

  1. Use grep or ls to map the repository first.
  2. Read only relevant sections of files (using offset and limit in Read tool) rather than ingesting 100% of large source files.
  3. Write the final report to a file (e.g., experiment_plan.md) rather than outputting thousands of words to stdout/chat, which triggers the "Bloviating" timeout/warning.

View original on GitHub ↗

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