subagent
A subagent is a separate AI agent that a main agent starts to handle a side task in a fresh context and then report back a summary. The main agent writes a task description, and the subagent works on it with its own system prompt, tool access, and context window. Only the final result returns to the main conversation, not every file the subagent read or every command it ran.
This isolation keeps the main context focused, so long searches or noisy logs don’t crowd out the original task. Several subagents can also run in parallel, for example one exploring a codebase while another drafts tests.
The trade-off is cost. Each subagent runs its own agent loop and rereads whatever it needs, so delegating work usually uses more tokens in total. Harnesses such as Claude Code ship built-in subagents and let users define their own.
Related Resources
Tutorial
AI Coding Agents Guide: A Map of the Four Workflow Types
AI coding agents come in four types: IDE, terminal, PR, and cloud. Learn how each workflow fits into modern Python development.
For additional information on related topics, take a look at the following resources:
- CrewAI in Python: Coordinating Teams of AI Agents (Tutorial)
- How to Use Claude Code to Write and Debug Python (Tutorial)
- AI Coding Agents Guide: A Map of the Four Workflow Types (Quiz)
- CrewAI in Python: Coordinating Teams of AI Agents (Quiz)
- Getting Started With Claude Code (Course)
- How to Use Claude Code to Write and Debug Python (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Sarah Jane Ross • Updated Oct. 12, 2026