Part 9 of 11 · 2 min read
Quick notes
- Context isolation means a sub-task runs in a separate agent with its own context window; the parent sees only what the sub-agent returns.
- It saves tokens because an agent re-reads its whole context on every step, so cost grows roughly with the square of the steps; four short contexts cost far less than one long one, and the saving grows with task length.
- It can lose information, because the parent only knows what crosses the boundary. A sub-agent that ends with "Done!" returns nothing.
- A typed result is the only return strategy in the example that kept every finding and the caveat while excluding injected text; returning the last message lost half the findings and returning everything let the injection through.
- Total cost is not the parent's cost: sub-agents still spend tokens. The saving comes from smaller contexts, not from less work.
The detail The full notes
- Context isolation means a sub-task runs in a separate agent with its own context window; the parent sees only what the sub-agent returns.
- Why it saves tokens: an agent re-reads its whole context on every step, so cost grows roughly with the square of the number of steps. Four sub-tasks of 15 steps in four contexts cost far less than 60 steps in one.
- Why it can lose information: the parent only knows what crosses the boundary. A sub-agent that ends with "Done!" returns nothing. Whether the information crosses depends on the result strategy.
- Quote these numbers, with the caveat that the task is synthetic (4 sub-tasks, 15 steps each, 2,000-token system prompt, 5 seeds):
- one agent keeping everything: 355,654 total input tokens;
- sub-agents returning a typed result: 178,517 (50 percent), the only strategy that returned all four findings, the caveat and no injected text;
- sub-agents returning the last message: 178,445 tokens but only half the findings and no caveat, because two sub-agents ended with "Done!";
- sub-agents returning everything: 186,446 tokens, all information, but 10,051 tokens in the parent and the injected instruction included.
- The saving grows with task length: the ratio of sub-agent cost to single-agent cost fell from 0.58 at 10 steps to 0.37 at 40 steps per sub-task.
- Total cost is not the parent's cost: sub-agents still spend tokens. The saving comes from smaller contexts, not from less work.