Skip to main content
Some jobs are large enough to pull the main loop off track. The usual fix is to hand that job to a helper — a sub-agent. A sub-agent is a helper process the main loop starts to handle a single, well-defined task. The main loop does not stop what it is doing: it spawns the sub-agent, gives it one clear instruction, and continues. The key word is one: a sub-agent is most effective when given a single, focused job to finish. What makes a sub-agent different from the main loop is that it starts fresh. It receives its own clean workspace and instructions and does not inherit the main loop’s long history. The sub-agent works on its one job, and then returns only the final answer. The main loop never sees the messy middle, just the result.
The image depicts a diagram showing "The Main Loop" and "The Subagent" with their respective features, illustrating a process titled "It Starts Fresh." The Main Loop has an infinity icon and features labeled "Answer" and "Long history," while the Subagent, depicted with a robot icon, has features "Clean workspace" and "Own instructions."
A simple instruction payload you might send to a sub-agent looks like this:
Think of a manager who assigns a task to a specialist. The specialist goes off, does the work, and returns a short, focused summary. The manager gets the result without living through every step. In this analogy, the sub-agent is the specialist and the main loop is the manager. Here are two common jobs for a sub-agent. Job one: searching a large codebase. If the loop needs to find every place a function is used across thousands of files, reading them all itself would flood its workspace with text and slow it down. Instead, it sends a search sub-agent to scan the files and report back a concise summary: for example, “the function is used in three places — here they are.” The loop receives the answer, not a dump of all files.
The image illustrates a task titled "Job One - Search a Big Codebase," showing icons labeled "The Loop," "Search Subagent," and "2,000 files," with a note that "The Loop" is used in three places.
Job two: checking work before saving. This pattern is often called the maker-and-checker.
The image illustrates a workflow titled "Job Two – Check Before Saving," showcasing three steps with icons: "The Change," "Check It," and "Then Save," indicating a process of reviewing changes before saving them.
One agent (the maker) produces the change. A different agent (the checker) reviews it. Why use a different agent? The maker tends to trust its own output and can miss mistakes. A fresh checker, given its own instructions — and sometimes implemented as a stronger model — inspects the change with new eyes and flags problems the original agent might miss. Splitting the roles this way catches errors that a single agent would overlook.
Use a separate checker when correctness matters. A fresh checker reduces confirmation bias and can be given stricter validation rules or a more powerful model.
A major advantage of sub-agents is containment of clutter. Big jobs generate lots of intermediate data: long search results, massive files, and extra context. If all that landed in the main loop, its working memory would fill up and reasoning would degrade. The sub-agent handles the messy work in its own space and returns a short, focused answer. The main loop only receives the distilled result.
The image illustrates a concept labeled "The Subagent Takes the Clutter," with sections for "The Subagent" having "its own space" and "The Main Loop" shown with a "Short answer" indication.
Sub-agents can also be intentionally minimal: they are given only the tools they need for the task. For example, a search helper might be granted read-only access to files but not permission to modify them. Keeping each helper small reduces cost, increases speed, and improves safety.
The image shows a "Search Subagent" icon with the text "Only the Tools It Needs" above it. Below the icon, it indicates the ability to "Read files" and "Change files."
Helpers can run in parallel. If multiple independent jobs can proceed at once, the main loop can spawn several sub-agents simultaneously. Each sub-agent works in its own workspace and reports back its own clean answer. Running side by side saves time while preserving the benefits of isolation.
The image depicts a diagram showing "The Loop" leading to three branches, each with a robot icon, under the theme "Run Side by Side." It includes a note indicating that this process "saves time."
In short, sub-agents provide focus, speed, and safety. Each one starts fresh, performs a single job, and hands back a clean answer. They remove heavy, messy work from the main loop, keep its working memory tidy, allow concurrent progress, and give the system ways to check itself with fresh eyes.
The image illustrates three key concepts: Focus, Speed, and Safety, each represented with an icon and associated actions like "Fresh start," "Off the plate," and "Clean memory."
Recap: a sub-agent is a helper started by the main loop to handle one clear job. It begins with its own workspace and instructions, performs the work, and reports back a short answer so the main loop stays focused. Good uses include searching large codebases and implementing a maker-and-checker workflow. Helpers can also be run side by side to save time.
The image lists "Good Uses" for three activities: searching a codebase, using a maker and checker approach, and side-by-side comparison, each with corresponding icons and benefits like "fresh eyes" and "saves time."
Best practices
  • Give each sub-agent a single, unambiguous task and a bounded scope.
  • Limit access: grant the minimal permissions (e.g., read-only) needed for the task.
  • Return only the distilled result (summary, list of hits, or a yes/no verdict) rather than raw intermediate data.
  • Use separate checkers for high-stakes outputs to reduce confirmation bias.
  • Run independent sub-agents in parallel when possible to reduce wall-clock time.
Quick reference table Links and references

Watch Video