Part 7 of 11 · 2 min read
Answering sub-agent-isolation questions in an interview
Why use sub-agents instead of one agent with a long context?
"Cost and reliability. An agent re-reads its whole context at each step, so one agent doing 60 steps pays about four times the quadratic term of four agents doing 15. And a long context degrades accuracy, as module 6 showed. Isolation keeps each context short, and the parent holds only results. In the example's simulation it halved total tokens, and the saving grew from 42 to 63 percent as sub-tasks went from 10 to 40 steps." Follow-up: "What do you give up?" Information at the boundary. The parent can no longer see why a child concluded something, so I need a result contract that carries evidence and caveats.
What should a sub-agent return?
"A typed record rather than its last message: the answer, a pointer to evidence, caveats, and a status. In the example's test the last message lost half the findings because two children ended with 'Done!', and returning the last few messages carried an injected instruction up to the parent. A schema makes the contract checkable, and I validate it on the parent side." Follow-up: "Is a schema enough?" No: a free-text field can still hold an instruction, and a model can fill a field wrongly. I keep authority-bearing actions out of children that read untrusted content and treat results as data.
How does isolation relate to prompt injection?
"It limits the blast radius. Untrusted content is read in a child with no or few permissions, and only a validated result reaches the parent, which holds the privileged tools. It is containment, not prevention: if the result strategy returns raw messages, the injection crosses, as in my 'last three' and 'everything' rows." Follow-up: "What else?" Least-privilege tools per agent, human confirmation for side effects, and never letting returned text become an instruction.
Does splitting into sub-agents always save tokens?
"No. Each child pays its own system prompt and the parent pays for the handoffs, so for short sub-tasks the overhead can outweigh the quadratic saving. The saving also disappears if the parent needs the child's full trace. I compare total tokens across agents against the single-agent run on the real workload." Follow-up: "What about caching?" Children sharing a system prompt and tools can share a cached prefix (module 7), which reduces the overhead; a reordered tool list in one child breaks that.