Skip to content

Instantly share code, notes, and snippets.

View peterdresslar's full-sized avatar
🌊

Peter Dresslar peterdresslar

🌊
View GitHub Profile
@will-deines
will-deines / avoiding-subagent-context-overflow.md
Created February 9, 2026 15:31
Claude Code: Avoiding subagent context overflow with file-based result passing

Avoiding Subagent Context Overflow in Claude Code

When Claude Code skills or prompts orchestrate multiple background subagents, a subtle but devastating problem emerges: context overflow from agent transcripts. This guide explains the problem, when it matters, and the battle-tested solution.


The Problem

When you launch a background subagent with the Task tool (run_in_background: true), the natural instinct is to call TaskOutput to collect its results. But TaskOutput doesn't return just the agent's final answer — it returns the entire agent transcript: every web page fetched, every search result, every tool call, every reasoning step.