Lesson 11.12 · 20 min · video lesson
Subagents: Delegating Tasks Within an Agent Network
Why would an AI agent hand part of its own job to another AI agent, and then throw away almost everything that helper read?
In short: A subagent is a helper agent that a main agent starts for one focused subtask. It runs with its own fresh context window, its own instructions and often a restricted set of tools, and it returns only a short result. This keeps the main agent's context clean, allows parallel work and lets us give each helper only the permissions it needs.
What you will learn
- What is an AI Agent?
- What are AI SubAgents?
- Why do we need SubAgents?
- How do SubAgents work?
- Example use case
- Benefits of using SubAgents
- Challenges with SubAgents
- Best practices
In this lesson
- What is an AI agent?
- What are AI subagents?
- Why do we need subagents?
- How do subagents work?
- Example use case, in code
- Benefits and challenges
- Best practices
- Worked example, step by step
- Practice: try it yourself
Key terms in this lesson
- Subagent
- An agent started by another agent to do one subtask in its own context and return a result.
- Main agent
- The agent that holds the user conversation, plans the work and delegates to subagents.
- Context window
- The maximum number of tokens a model can read in one call.
- Context pollution
- Filling the context with large, mostly irrelevant tool output, which raises cost and can lower quality.
- Brief
- The task description handed to a subagent; its only knowledge of the larger job.
- Least privilege
- Giving each agent only the tools and permissions its job requires.
This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).
← 11.11 Multi-Agent Systems: Dividing Work Among Specialist Agents · 11.13 Agent Communication: Protocols and Message Formats →