Modern AI Engineering

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

  1. What is an AI agent?
  2. What are AI subagents?
  3. Why do we need subagents?
  4. How do subagents work?
  5. Example use case, in code
  6. Benefits and challenges
  7. Best practices
  8. Worked example, step by step
  9. 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 →