AgentTool: Sub-Agent Scheduler
7/31/2026, 8:55:39 PM · updated 7/31/2026, 9:00:46 PM
AI-translated on 7/31/2026, 9:03:43 PM · by Qwen3.6 35B (fast, default)
AgentTool is a controlled task dispatcher in Claude Code, used to create and manage sub-agents to execute sub-tasks when the main thread's workload becomes too large.
AgentTool is the core scheduling component of Claude Code. It encapsulates "task decomposition, sub-agent execution, and lifecycle management" into a formal tool, marking this framework's architectural evolution from a single-threaded code assistant to a multi-task agent system. Through a controlled dispatch mechanism, independent context trimming, and complete workflow binding, it solves issues of parallel processing and main thread context pollution in complex task scenarios.
Core Problems Solved and Tool Positioning
AgentTool is one of the most representative tools in Claude Code. It doesn't solve single-point capabilities like "reading files" or "running commands," but rather:
When the main thread model determines that a task is too large, too complex, or ideally suited for parallelization, how to decompose part of the work for another agent to handle. This is one of the core dividing lines between Claude Code and standard code assistants. Many AI tools rely on a single main thread model running straight through, whereas Claude Code explicitly supports:
- Research-oriented subtasks
- Background execution
- Multi-agent collaboration
- Local/remote sub-agents
Core Parameters Exposure
tools/AgentTool/AgentTool.tsx exposes its core parameters right from the start:
const baseInputSchema = z.object({
description: z.string().describe('A short (3-5 word) description of the task'),
prompt: z.string().describe('The task for the agent to perform'),
subagent_type: z.string().optional(),
model: z.enum(['sonnet', 'opus', 'haiku']).optional(),
run_in_background: z.boolean().optional(),
})
These fields clearly illustrate its positioning:
description: a brief title for the subtaskprompt: the actual work handed off to the sub-agentsubagent_type: selecting a specifically typed agentmodel: switching models when necessaryrun_in_background: executing asynchronously in the background In essence,AgentToolis a task dispatcher.
Position in the System Architecture
Within Claude Code's overall tool pool, it is placed at the very front:
export function getAllBaseTools(): Tools {
return [
AgentTool,
TaskOutputTool,
BashTool,
...
]
}
This doesn't necessarily mean "most frequently called," but it does indicate that Anthropic views it as a foundational core capability. Because once AgentTool is available, other tools are no longer just "for the main thread to use directly" but can be further invoked by sub-agents.
Its position in the system:

Underlying Mechanism and Controlled Dispatch Logic
More Than Just "Spinning Up Another Model"
Looking at the imports in AgentTool.tsx reveals that this tool actually bridges numerous subsystems behind the scenes:
import { enhanceSystemPromptWithEnvDetails, getSystemPrompt } from '../../constants/prompts.js'
import { assembleToolPool } from '../../tools.js'
import { runAgent } from './runAgent.js'
import { registerAsyncAgent } from '../../tasks/LocalAgentTask/LocalAgentTask.js'
import { registerRemoteAgentTask } from '../../tasks/RemoteAgentTask/RemoteAgentTask.js'
This means AgentTool does at least four things:
- Regenerates the sub-agent's system prompt
- Reassembles a dedicated tool pool
- Determines whether it's a local or remote task
- Registers the sub-agent within the task system Its true nature is better described as:
Starting a controlled work thread with task context, leveraging Claude Code's runtime framework.
Why Sub-Agents Don't Become "Uncontrolled Forks"
If it simply forked a model blindly, the system would quickly spiral out of control. Claude Code constrains it through several layers of mechanisms:
- Each sub-agent has its own input schema
- Each sub-agent reconstructs its own prompt
- Each sub-agent's tool pool is filtered independently
- Each sub-agent is registered into the task system, supporting status tracking, output retrieval, cancellation, and notifications
Thus,
AgentToolis not a "free-form cloning tool," but a controlled dispatcher. The call chain can be examined in more detail:
Task Lifecycle Binding and Tool Collaboration
Tight Coupling with the Task System
Claude Code doesn't let sub-agents run secretly in the background; it treats them as formal tasks:
- Output is viewable
- Capable of background execution
- Can be stopped/cancelled
- Can be resumed/recovered
This is precisely why
TaskOutputToolimmediately followsAgentTool. They natively function as a pair: AgentToolhandles task dispatchingTaskOutputToolhandles result retrieval
Typical Execution Path
A typical path can be understood as follows:
- The main thread identifies that "this problem requires deep investigation into a specific subsystem"
- The main thread invokes
AgentTool - The sub-agent independently searches, reads files, reasons, and executes
- The sub-agent delivers a compressed conclusion
- The main thread takes this conclusion to continue advancing Compared to "the main thread executing all searches itself," the greatest advantages are:
- Reduced main context pollution
- Easier parallelization
- Better suited for heavy research and deep-dive troubleshooting tasks
Relationship with Adjacent Tools

- Works with
TaskOutputTool: reads sub-agent output - Works with
SendMessageTool: enables mutual communication in multi-agent mode - Works with
BashTool,Read, andEdit: allows the sub-agent to continue completing tasks independently - Works with
SkillTool: certain skills are executed within an independent sub-agent
Clarifying Common Misconceptions
🚫 Misconception 1: AgentTool is just multi-turn conversation
No. It is a definitive tool invocation, complete with schema, task lifecycle, and result injection.
🚫 Misconception 2: Sub-agents are identical to the main thread
Also no. A sub-agent's prompt, tool pool, and execution mode can all differ.
🚫 Misunderstanding 3: AgentTool is just a "more advanced prompt"
Not entirely accurate. It's more like "integrating another Agent as a formal runtime object into the system".
Key takeaways
AgentToolis not a single-point capability tool, but rather the scheduling hub encapsulating task decomposition, subprocess execution, and lifecycle management within Claude Code.- Through independent schemas, prompt restructuring, tool pool isolation, and binding to the Task system, sub-agents are strictly constrained as controlled dispatch targets, rather than autonomous clones.
- Naturally paired with
TaskOutputTool, it forms a standardized workflow of "main thread dispatch → context-isolated processing → result return". - The core business value lies in reducing main context pollution and enabling native parallelism, providing architectural-level support for research-oriented and deep investigation tasks.
Learning map
Learning Map
Stage 1 – Foundations
- Understand the purpose of AgentTool and how it differs from single‑call tools.
- Read the base input schema (
description,prompt,subagent_type,model,run_in_background).
Stage 2 – Integration Basics
- Learn how AgentTool is positioned in the global tool pool (first entry).
- Explore the four internal steps it performs: system‑prompt enhancement, tool‑pool pruning, task type selection, and registration with the task system.
Stage 3 – Practical Use
- Pair AgentTool with TaskOutputTool to retrieve sub‑agent results.
- Experiment with background execution and model overrides.
Stage 4 – Advanced Patterns
- Combine AgentTool with SendMessageTool for multi‑Agent communication.
- Use BashTool, Read/Edit tools inside a sub‑agent for complex workflows.
- Implement custom
subagent_typeto specialize agents for research, debugging, or data extraction.
Stage 5 – Production Ready
- Monitor task lifecycle (status, stop, resume) via the task system UI.
- Apply best‑practice patterns for error handling and result validation.
Get hands-on — step by step
- Open your Claude Code project and locate
tools/AgentTool/AgentTool.tsx. - Add a new entry in your workflow script that calls AgentTool with:
{ "description": "Search API docs", "prompt": "Find the authentication flow for the Anthropic API and summarize it.", "subagent_type": "research", "model": "sonnet", "run_in_background": true } - Immediately after the AgentTool call, invoke TaskOutputTool with the task ID returned in step 2 to fetch the sub‑agent’s result.
- Print the retrieved summary to the console or feed it into the next stage of your main agent.
- Test the flow:
- Run the script.
- Verify that a background sub‑agent is created (check the task dashboard).
- Confirm the output matches the expected API documentation summary.
- Experiment: change
run_in_backgroundtofalseand observe synchronous execution, then trymodel": "opus"for a higher‑capacity model.
Top 3 sources
- 1Anthropic Claude Documentation – Tool Use
Official guide that explains how Claude tools work, including schema definitions and execution semantics.
https://docs.anthropic.com/claude/docs/tool-use
- 2Claude API Reference – Tools Section
Detailed reference for all built‑in tools, with examples of AgentTool usage and parameters.
https://docs.anthropic.com/claude/reference/tools
- 3Anthropic News – Introducing Claude Code
Announcement blog post describing the multi‑agent capabilities of Claude Code and the role of AgentTool as a task dispatcher.
https://www.anthropic.com/news/claude-code
Links are AI-suggested — worth a quick sanity check before diving in.