Why subagents?
Subagents solve the context bloat problem. When an agent uses tools with large outputs — API responses, search results, file contents — the context window fills up with intermediate data that is only needed temporarily. As the context grows, the agent becomes slower, more expensive, and more prone to errors. Consider a task: “Summarize the recent pull requests for every member of my team.”- Without subagents
- With subagents
- The agent looks up members of the team.
- It works on each member one by one, fetching pull requests and summarizing each.
- All intermediate tool calls and results stay in the context window.
- The agent has to reason over a large, cluttered context to produce the final answer.
- The bloat carries over to future turns in the session.
- Multi-step research across several entities (users, repos, services) that can run in parallel
- Tasks where intermediate tool output is large but the final answer is a summary
- Work that benefits from isolation — each subtask gets a clean context to reason in
How it works
The root agent decides at runtime whether to delegate. When it does, it calls the built-increate_sub_agent tool with focused, generated instructions for each subtask, spawns the subagents, and waits for their results.
- Shared tools and sandbox — subagents have access to the same MCP tools and sandbox environment as the root agent.
- No user interaction — subagents cannot ask the user questions. Only the root agent talks to the user. Subagent tool calls that require approval still pause for the user, though.
- No nesting — subagents cannot create other subagents. Delegation is one level deep.
- Parallel execution — multiple subagents run concurrently. The root agent waits for all of them before continuing.
Example
In this example, the user asks for a summary of work merged by a team. The root agent looks up team members, then delegates PR research for each member to parallel subagents.User
Can you please give me a summary of work merged by “agent” team in agent-runtime in last 7 days?
Assistant
get_team_members
get_team_members
Tool CallTool Response
Assistant
These subagents run in parallel and return their final assistant messages to the main agent.
The main agent waits for all the subagents to finish and then combines the results to produce the final answer.
Subagent: bob-prs
Subagent: bob-prs
System
These instructions are generated by the main agent for the subagent to execute.
- query: “repo:truefoundry/agent-runtime author:bob is:merged merged:>=2026-05-15”
- PR number and title
- Merged date
- A brief 1-2 sentence description of what the PR does (infer from the title or any available description)
Assistant
search_pull_requests
search_pull_requests
Tool CallTool Response
Assistant
- Merged: 2026-05-20 Description: Adds a new responseUpdatedAt timestamp field to ResponseInStore …
- Merged: 2026-05-19 Description: Fixes sandbox initialization by symlinking the uploaded mcp_client.py as mcp-client
Subagent: alice-prs
Subagent: alice-prs
System
These instructions are generated by the main agent for the subagent to execute.
- query: “repo:truefoundry/agent-runtime author:alice is:merged merged:>=2026-05-15”
- PR number and title
- Merged date
- A brief 1-2 sentence description of what the PR does (infer from the title or any available description)
Assistant
search_pull_requests
search_pull_requests
Tool CallTool Response
Assistant
No PRs merged by alice in the last 7 days.
Assistant
Here is a summary of work merged by the agent team in the last 7 days:
- Alice: No PRs merged in the last 7 days.
- Bob: 2 PRs merged in the last 7 days. The theme of work is around sandbox initialization and responseUpdatedAt … …
Disabling
Setconfig.dynamic_sub_agents.enabled: false on the agent. See config.dynamic_sub_agents in the agent spec reference.