Wiki · concept

Sub-agents keep the primary context focused

Delegating search-heavy or exploratory work to a sub-agent keeps the main context window clean. The primary thread focuses on the actual change while the sub-agent reads, searches, and reports back. This pattern handles complex tasks without filling the window with intermediate exploration.

The pattern works because context windows are zero-sum. Every file the agent reads for exploration is a file it cannot hold when doing the actual work. By delegating the exploration to a sub-agent that reports back a summary, the primary context stays reserved for the change at hand. The tradeoff is coordination overhead: the sub-agent’s summary must be accurate enough to act on. In practice, this pattern shines for large refactors where the agent needs to understand cross-file dependencies before making a single edit.