Agent & Task Tools
Claude Code's multi-agent system is built on a set of tools for spawning subagents, inter-agent messaging, and task lifecycle management.
AgentTool
The primary tool for spawning subagents that perform work in isolated contexts. AgentTool supports both foreground (blocking) and background (async) execution modes.
Parameters
The task for the agent to perform.
A short (3-5 word) description of the task. Displayed in the UI.
The type of specialized agent to use. Maps to agent definitions loaded from the agents directory. Defaults to a general-purpose agent.
Model override: "sonnet", "opus", or "haiku". Takes precedence over the agent definition's model.
Run the agent in the background. You will be notified when it completes.
Isolation mode: "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo. "remote" launches in a remote environment (internal only).
Absolute path to run the agent in. Overrides the working directory. Mutually exclusive with isolation: "worktree".
Name for the spawned agent. Makes it addressable via SendMessage({to: name}) while running.
Execution Modes
The default mode. The parent agent blocks while the subagent runs. The subagent's result is returned directly. Progress is streamed to the UI.
Agent Types
Agents can be specialized through agent definitions loaded from the .claude/agents/ directory. Each definition specifies:
- A system prompt or instructions
- Model preferences
- Required MCP servers
- Tool restrictions
Built-in agent types include a general-purpose agent and a one-shot verification agent.
When background tasks are disabled (CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=true) or fork subagent mode is enabled, the run_in_background parameter is hidden from the schema.
Auto-Background
Foreground agents automatically transition to background after 120 seconds (when enabled via CLAUDE_AUTO_BACKGROUND_TASKS or the tengu_auto_background_agents feature flag). The 2-second progress threshold controls when the background hint appears in the UI.
Key Properties
- Read-only: No
- Concurrency-safe: No
- maxResultSizeChars: 100,000
SendMessageTool
Sends messages between agents in a multi-agent team setup.
Parameters
Recipient: a teammate name, "*" for broadcast to all teammates, "uds:<socket-path>" for local peers, or "bridge:<session-id>" for Remote Control peers.
Plain text message content, or a structured message object (shutdown_request, shutdown_response, plan_approval_response).
A 5-10 word summary shown as a preview in the UI. Required when message is a string.
Structured Messages
SendMessageTool supports typed message payloads for protocol-level communication:
type StructuredMessage =
| { type: 'shutdown_request', reason?: string }
| { type: 'shutdown_response', request_id: string, approve: boolean, reason?: string }
| { type: 'plan_approval_response', request_id: string, approve: boolean, feedback?: string }Routing
Messages are routed through the teammate mailbox system. The tool resolves recipient names against the current team context, finds the matching teammate's agent ID, and queues the message for delivery.
Task Management Tools
The Task tools provide CRUD operations for a shared task list used to coordinate work across agents.
Task tools are enabled when isTodoV2Enabled() returns true. They replace the older TodoWriteTool for structured task management.
TaskCreate
Creates a new task in the shared task list.
A brief title for the task.
What needs to be done.
Present continuous form shown in the spinner when in progress (e.g., "Running tests").
Arbitrary metadata to attach to the task.
TaskUpdate
Updates an existing task's fields.
The ID of the task to update.
New subject for the task.
New description.
New status: "pending", "in_progress", "completed", or "deleted".
New owner for the task.
Task IDs that this task blocks.
Task IDs that block this task.
TaskGet
Retrieves a single task by ID. Returns the task's subject, description, status, and dependency information (blocks, blockedBy).
The ID of the task to retrieve.
TaskList
Lists all tasks in the shared task list. Takes no parameters. Returns tasks with their ID, subject, status, owner, and blocking dependencies. Completed tasks' IDs are automatically filtered from other tasks' blockedBy arrays.
TaskStop
Stops a running background task by ID. Works for both background shell tasks and background agent tasks.
The ID of the background task to stop.
Deprecated: use task_id instead. Kept for backward compatibility with the old KillShell tool name.
Key Source Files
src/tools/AgentTool/AgentTool.tsx: Agent spawning with sync/async/worktree modessrc/tools/AgentTool/runAgent.ts: Agent execution loopsrc/tools/SendMessageTool/SendMessageTool.ts: Inter-agent messagingsrc/tools/TaskCreateTool/TaskCreateTool.ts: Task creationsrc/tools/TaskUpdateTool/TaskUpdateTool.ts: Task updates with status transitionssrc/tools/TaskGetTool/TaskGetTool.ts: Single task retrievalsrc/tools/TaskListTool/TaskListTool.ts: Task listingsrc/tools/TaskStopTool/TaskStopTool.ts: Background task termination