Sub topic 7
What to Pass Between Agents
This chapter assumes you know how an agent loop works, how tool calling works, and the difference between a handoff and an orchestrator. It covers what context one agent should give the next one.
Two ways context moves
The two patterns pass context differently.
- Handoff: the next agent continues the same message history. It sees everything the earlier agents saw, including tool results.
- Orchestrator: each specialist starts with a fresh history that holds only the task text the orchestrator gives it. It returns a string.
In the orchestrator pattern, the task text is the only context the specialist gets. A vague task such as "write the summary" produces a vague result.
The cost of passing everything
Passing the full history after a handoff is simple, but it has three costs:
- Long histories raise token cost and latency on every later turn.
- Irrelevant details can distract the next agent.
- The next agent sees data it may not need, such as another customer's lookup result or internal notes.
Passing too little also fails. The next agent may ask the user for facts they already gave, or repeat a tool call.
A structured payload
A middle path is a compact payload with a fixed shape. It states what the next agent needs and nothing else.
from dataclasses import dataclass, asdict
import json
@dataclass
class HandoffPayload:
goal: str
facts: list[str]
open_questions: list[str]
constraints: list[str]
payload = HandoffPayload(
goal="Issue a refund for order 1042",
facts=["Customer reports a damaged item", "Order was delivered on time"],
open_questions=["Does the refund exceed the auto-approval limit?"],
constraints=["Do not promise a replacement"],
)
message = {"role": "user", "content": json.dumps(asdict(payload))}Each field has a job:
| Field | Purpose |
|---|---|
| `goal` | What the next agent must achieve |
| `facts` | Verified information it can rely on |
| `open_questions` | What is still unknown |
| `constraints` | Limits it must respect |
Keeping facts separate from open_questions stops the next agent from treating a guess as settled.
Choosing what to include
Use these rules when you design a payload:
- Include the goal in one sentence.
- Include only facts the next agent will act on, and say where each came from if it matters.
- Pass identifiers such as an order number, not whole records. The next agent can look the record up with its own tools.
- Carry forward constraints from earlier agents. A constraint dropped at a handoff is lost.
- Leave out reasoning and failed attempts unless the next agent needs them to avoid repeating the work.
Common errors
- Lost constraints. The first agent was told not to promise replacements, but the payload omitted it. Always list constraints explicitly.
- Free-text summaries. Prose summaries vary in shape and drop details. A fixed schema is easier to check and test.
- Context bloat in orchestrators. The orchestrator appends every specialist result to its own history. Ask specialists for short results, and trim before you append.
- Missing task detail. A specialist task should say the goal, the inputs, and the expected output format.
Exercise
A triage agent hands a billing question to a billing agent. The user has already said their order number and that they must not be charged a fee. Which payload fields hold these two pieces of information, and why not just pass the whole history?
Show answer
The order number belongs in facts (or inside goal), and the no-fee requirement belongs in constraints. A payload is better than the whole history because it costs fewer tokens, avoids distracting or exposing unrelated content, and states the limits explicitly so they are not lost.