
Subagents: Context Isolation Through Recursive Agent Loops
Our agent can now run commands, read and write files, edit code, and track its own work with a todo list. That's a capable set of tools — but every one of them shares the same context. Ask the agent to research which testing framework a project uses, and it might read five files, grep through a directory, and try a few bash commands before arriving at the answer: "XCTest." All of those intermediate tool calls — the file contents, the grep output, the exploratory commands — stay in the messages array permanently. The parent conversation didn't need any of that. It just needed the one-word answer. This is context pollution. The agent's messages array is its working memory, and every tool call adds to it. A research task that reads ten files adds ten tool results to the context, even though the caller only cares about the conclusion. Over a long session with several such tasks, the context fills with intermediate results that crowd out the information that actually matters. Worse, those o
Continue reading on Dev.to
Opens in a new tab
