27.4 What a subagent gets, and what it hands back
- Approved by
- Panaversity ·
In everyday life. A tailor sends an apprentice to the cloth market with a written note. It says three meters of blue cotton, from one of two stalls, under a set price, and bring the receipt. The apprentice comes back and says one line: "Bought, three meters." The tailor does not ask about the walk. The shop's owner compares that line with the receipt. Then a second tailor measures the cloth with his own tape. He does not ask the apprentice how long it is. In this section, the note is the brief, and the one line is the subagent's answer. The receipt is the subagent's tool results, and the second tailor is an independent checker.
What you will learn. You practice this in Lab 27, Task 1.
- What goes in, and who writes each part?
- What comes back, and how can code check it?
- When is a separate checker independent?
- May a subagent start subagents of its own?
Why it matters. The parent never sees a subagent's work, only its answer. So a wrong answer and a right one look the same to the parent. Your code can check in two places: on the way in, and on the way back.
At work. Before the orchestrator's first run on Wednesday, May 5, 2027, you look at vendor-lookup again. You wrote its definition, and that part is fixed. But the sentence the orchestrator sends it for V001, Midwest Packaging Co., will be written by the model during the run. And when one line of terms comes back, the orchestrator will take it as true. So you ask two things now: what may go in, and how code will know that the line is what find_vendor returned.
What goes in, and who writes each part?
Two things go in. Your code writes the subagent's definition before the run, and the model writes the brief during it. What a subagent receives, and what it never receives, is 26.5's table.
The agent definition is the object in your code that describes one subagent. On the Claude Agent SDK it has two required fields, description and prompt.1 The rest are optional. Four matter for this chapter's table:
| Field | What it sets |
|---|---|
description | What the subagent is for. The orchestrator reads it to decide when to use the subagent (27.3) |
prompt | The subagent's own system prompt, with every rule it must follow |
tools | The tools it may ask for: "listing one doesn't pre-approve it. If omitted, inherits every tool available to subagents" |
maxTurns | Its own turn limit. At the limit, its output comes back "marked as partial" |
So always write the tools list. A subagent gets only the tools its step needs, which is why vendor-lookup has find_vendor and no other. A subagent that cannot call a tool cannot be tricked into misusing it. The list says what a subagent may ask for. It does not approve a call. Permission rules and hooks do that (22.5). A hook is your code, run at a set moment such as before every tool call. How both reach a subagent is Chapter 28's subject.
maxTurns is the stop that column 6 of docs/architecture.md asks for. An output marked as partial is not a finished answer, and your check must not treat it as one.
The brief is the prompt string the parent passes for this one job. In an orchestrator the model writes it. Anthropic lists what a good one holds: "Each subagent needs an objective, an output format, guidance on the tools and sources to use, and clear task boundaries."2 Without them, subagents "duplicate work, leave gaps, or fail to find necessary information."2
Your code cannot write the model's brief. It can put the parts that never change into the definition's prompt, where they apply whatever the brief says. vendor-lookup already has its output format and its boundaries there: one line, word for word, and "Never pay, approve or change anything." And the trace records each brief, as the input of the call that started the subagent, so you can read what the model really sent.
What comes back, and how can code check it?
One final message comes back. Code checks it against the subagent's own tool results, which your trace holds. On the Claude Agent SDK, a subagent's tool calls and results "stay inside the subagent", and "only its final message returns to the parent."1 The documentation adds: "The parent receives the subagent's final report, but may summarize it in its own response."1
So a value can change in two places: between the tool result and the subagent's answer, and between that answer and the parent's review. The parent cannot catch the first change, because it never saw the tool result. Your code can. The trace holds the subagent's calls as well as the parent's, and 27.6 shows how it marks them.
This is why the form of the answer matters. Lab 26's check by code fails a review if a policy line "was not returned by search_policy in that run". Suppose the orchestrator hands the policy search to a subagent. The search results are now in the subagent's part of the trace, and the check must read them there. It can do so only if the answer gives the line as (file.md:N). Code can compare that with a tool result. It cannot compare a sentence in the subagent's own words.
Figure 27.3. The brief goes in and one short answer comes back. The subagent's tool results go to your trace, where the check by code compares them with the answer. They never reach the parent.
The price is what the helper cannot say. A subagent limited to one line cannot tell the parent about something else it found. When the parent needs the details to decide, that part of the job should stay in one window (26.5).
When is a separate checker independent?
When it has three things: its own context, its own access to the source, and a check it can run, not a transcript it reads. A subagent whose only job is to test another agent's work is a checker. Anthropic calls it a "verification subagent". The main agent starts one "with the artifact to verify, clear success criteria, and tools to perform verification."3 The artifact is the piece of work to be tested.
Each of the three can be missing:
- Its own context. A checker that starts with the worker's conversation starts with the worker's mistakes. Anthropic notes that a verifier can test a result "without needing the full history of how it was built."3
- Its own access to the source. A checker of Brightline's review needs
list_open_invoicesandsearch_policyitself. If it gets only the worker's summary of what those tools returned, it checks the worker's story against the worker's story. - A check it can run. "Does this review look complete?" asks for an opinion. "Call
list_open_invoicesand name every invoice with no entry" is a test.
A checker is still a model. It judges, and it can be wrong, so a check by code stays the final test (23.16). Where code can run the test, as it can for a missing invoice, use code. A checker is worth its tokens only on a question that code cannot answer.
May a subagent start subagents of its own?
Only as deep as your code allows. On the Claude Agent SDK the depth is one of the five limits of 27.3. On Claude Managed Agents, in beta when this page was checked, "Delegation is one level deep".4 Least privilege has the same form on that platform: "To limit an agent's access, declare only the servers it needs in its agent definition."4 A subagent's thread there has no turn limit of its own. The API reference for creating a session lists none.5 Its stop is the session's budget, which every thread shares: "there are no per-thread caps".6 Section 27.7 lists these settings with their dates.
Every level adds one more brief and one more answer, so it adds two more places for a value to change.
The operating rule: fix what you can in the definition, and read the brief in the trace. Ask for an answer in a form that code can test against the subagent's own tool results.
Do this now. Ask your coding agent to show both ends of one subagent. Copy this line:
Show me one subagent this project defines: its description, its prompt, its tools and its turn limit, and say which of these is not set. Then write the brief a parent should send it for one vendor, with an objective, an output format, the tools to use and what it must not do. Mark which of those four the definition's prompt already fixes. Last, say which tool result a check by code would compare its answer with. Change no file.
Check yourself
Question 1 / 7
0 answered
The orchestrator sends vendor-lookup one sentence about V001. Who wrote that sentence, and when?
Sources
- Owner
- Panaversity