Skip to content
Claude Certified Architect – Foundations (CCAR-F) Exam Prep

Lesson 3 of 30 · 6 min

x
3/30

Subagent Invocation and Context Passing

Video lesson: CCAR-F 03/30: Subagent Invocation and Context Passing

What a subagent receives

A normal (non-fork) subagent starts with a fresh context. It gets:

  • its own system prompt (AgentDefinition.prompt) plus the Agent tool's prompt string
  • project CLAUDE.md (unless omitClaudeMd is set)
  • tool definitions (inherited, or the subset in tools)

It does not get the parent's conversation history, the parent's tool results, the parent's system prompt, or skills unless listed in skills.

> The only content you pass from parent to subagent is the Agent tool's prompt string. Include file paths, error messages and decisions it needs directly in that prompt.

Defining a subagent

AgentDefinition fields: description (required; tells Claude when to use it), prompt (required), tools, disallowedTools, model, skills, memory, mcpServers, maxTurns, background, effort, permissionMode.

  • Omit tools and it inherits every tool available to subagents. List tools and it gets only those; an omitted tool is simply absent, with no error.
  • The Agent tool must be available to the parent (include "Agent" in allowedTools) for delegation to work.
  • Invocation: automatic (Claude matches the task to description, so write clear, specific descriptions) or explicit (name the subagent in the prompt).
  • Programmatic agents override filesystem agents (.claude/agents/) with the same name.

What comes back

Only the subagent's final message, and the parent may summarise it. To keep it verbatim in the user-facing answer, say so in the instruction you give the main agent.

Practical rules (design guidance built on the above)

  • Pass facts, not references to conversation ("as discussed above" means nothing to a subagent).
  • Pass structured context with sources attached so the coordinator can keep provenance.
  • Give each subagent the narrowest tool set that does its job.
  • Cap work with maxTurns; a subagent that hits it returns output marked partial and can be resumed.

Exam traps

  • Assuming the subagent inherits the conversation. It does not (except a fork).
  • Forgetting "Agent" in allowedTools, so delegation never happens.
  • Vague description, so Claude never picks the subagent.
  • Giving every subagent every tool.
  • Detecting delegation only by "Task". Current SDKs emit "Agent" in tool_use blocks (the init tools list still says Task); match both.

References

  1. Subagents in the SDK — checked Oct 16, 2026

Check your understanding

  • A subagent must fix "the bug we just found". Why might it fail?Show answer

    Answer

    It never saw the conversation; the prompt must contain the file, error and context.
  • How do you make a subagent read-only?Show answer

    Answer

    tools: ["Read", "Grep", "Glob"].
  • Claude is answering directly instead of delegating. Two fixes?Show answer

    Answer

    Name the subagent in the prompt; write a clearer description.
Previous

Progress is saved in this browser.

Next Lesson