Agent Sessions
Subagent Hygiene
The most expensive thing in a long coding session is the main context window, because everything in it is re-billed on every turn. Subagents fix this: they do the noisy searching in their own throwaway context and hand back only the conclusion — turning an 11K-token inline search into a 400-token summary your main thread keeps.
The Problem With Searching Inline
Run a codebase-wide search in your main thread and every match lands in your window: every file excerpt, every false positive, every "close but not it" result. You wanted one answer — where is the rate limiter configured? — and you're now carrying the entire expedition. Worse, you keep carrying it: because the whole context is re-sent on each request, an 11K-token search kept for the rest of a long session is re-billed dozens of times. Across a heavy session that single pattern is worth roughly $150 a year, and it's usually repeated several times a day.
The signal-to-noise ratio makes it sting. Of those 11K tokens, the part you actually needed was one file path and a line number — perhaps 40 tokens. Everything else is exhaust from the process of finding it.
The Pattern: Fan Out the Mess, Keep Only the Answer
A subagent is a separate model invocation with its own fresh context. Hand it the broad search or the multi-file sweep. It reads dozens of files, follows dead ends, accumulates all the noise — in its own context, which is paid once and then discarded. What returns to your main thread is a one-paragraph conclusion:
Inline search: 11,000 tokens kept in main context,
re-billed every remaining turn
Subagent search: same work in a throwaway context,
~400-token conclusion kept, paid once
Claude Code's Task tool, and equivalent features in other agent harnesses, exist precisely for this. The main thread stays lean, which does more than save money: a clean history makes the model measurably better at later turns, because it isn't re-parsing search exhaust to find the thread of the actual task. This is the delegation half of the context window diet.
Three Rules of Subagent Hygiene
- Delegate anything broad. "Find where X is configured," "check every caller of this function," "which of these 30 files mentions the legacy API" — all subagent work. If the task fans out across many files and you need a conclusion rather than the raw material, it does not belong in your main thread.
- Ask for conclusions, not dumps. Tell the subagent what shape to return: the answer plus
file:linereferences — not the matching excerpts. A subagent that returns 8K tokens of quoted code has just moved the problem, not solved it. - Keep single-file work inline. Delegation has overhead — the subagent re-reads whatever orientation it needs. Reading one known file or making a sequential edit is cheaper done directly. The dividing line: fan-out and noise favor a subagent; a single target favors the main thread.
Verify It's Working
The point of the pattern is a main thread that stays small, and that's checkable. Terse's agent monitor shows per-source token usage across your sessions — watch the agent source while you work and you can see whether searches are landing in your main context or being absorbed by subagents. Pair the pattern with diff filtering and narrow file reads, and main-thread cost per turn typically drops by half or more.
Watch Your Main Thread Stay Lean
Terse tracks token usage per source across agent sessions, so you can confirm searches are going to subagents instead of bloating your main context. On-device, free to start.
Download TerseFrequently Asked Questions
What is a subagent in AI coding tools?
A subagent is a separate model invocation with its own fresh context window, spawned to handle a subtask — typically broad searches or multi-file analysis. It does the noisy work in disposable context and returns only a short conclusion to the main session.
When should I use a subagent instead of searching inline?
Delegate when the work fans out — codebase-wide searches, multi-file sweeps, checking many candidates — and you only need the conclusion. Work directly when reading a single known file or making sequential edits, where delegation overhead exceeds the savings.
Do subagents cost extra?
A subagent's own tokens are paid once, then discarded. That's almost always cheaper than the alternative: search noise sitting in your main context being re-billed on every subsequent turn for the rest of the session.
Further Reading
- Terse Blog — all token optimization guides
- Context Window Diet — the full window-management playbook
- Git Diff Compression — shrink the other big context filler
- Terse for Claude Code — per-source session tracking