Skip to Content
ToolsAgent ToolAgent Tool

Agent Tool

Source: src/tools/AgentTool/

Overview

The Agent Tool enables Claude Code to spawn sub-agents — independent Claude instances that handle complex, multi-step tasks autonomously. This is the foundation of the multi-agent architecture.

Parameters

  • prompt — Task description for the sub-agent
  • description — Short (3-5 word) summary
  • subagent_type — Agent specialization (optional)
  • run_in_background — Run asynchronously (optional)
  • isolation — Isolation mode, e.g., "worktree" (optional)
  • resume — Agent ID to resume (optional)

Agent Types

TypeTools AvailableUse Case
general-purposeAll toolsComplex multi-step tasks
ExploreRead-only toolsCodebase exploration
PlanRead-only toolsImplementation planning
statusline-setupRead, EditStatus line configuration

Execution Model

Isolation Modes

Default

Sub-agent works in the same directory as the parent.

Worktree

isolation: "worktree" creates a temporary git worktree, giving the sub-agent an isolated copy of the repository. Changes can be kept or discarded.

Background Execution

Agents can run in the background while the parent continues working:

  • Launch with run_in_background: true
  • Parent is notified when agent completes
  • Multiple agents can run in parallel

Resuming Agents

Agents can be resumed using their ID, continuing with full previous context preserved. This enables iterative workflows across multiple turns.

Deep Dive

  • Agent Lifecycle — Full lifecycle from spawn to completion: prompt construction, tool filtering, execution context
  • Isolation & Worktrees — Git worktree creation, cleanup, and file system isolation mechanics
  • Background Execution — Async agent execution, notification system, parallel coordination, and resumption
Last updated on