Context Engineering · 7 min read
Structured handoffs: using schemas and typed summaries so context survives the trip between agents
Most multi-agent failures happen in the gaps between agents, not inside them. Here's how to design handoffs as typed contracts — task briefs, result schemas and references — so the next agent gets what it needs and nothing it doesn't.
When one agent passes work to another, something has to cross the gap: the task, what’s been learned so far, the constraints, and what “done” looks like. In most systems that crossing is a paragraph of free text written by a model in a hurry. It’s no surprise that a lot gets lost.
This post is about treating that crossing as an interface. Give handoffs a schema, the way you’d give an API a request and response type, and context stops leaking between agents. (If you’re new to the topic, start with our posts on context engineering and agent orchestration patterns.)
The gap is where things break
The clearest evidence comes from Why Do Multi-Agent LLM Systems Fail? (Cemri et al., 2025). The authors had expert annotators study 200 execution traces from popular open-source multi-agent frameworks, including ChatDev, MetaGPT, AG2, HyperAgent and AppWorld, and sorted every failure into a taxonomy. Three top-level categories came out:
| Category | Share of failures |
|---|---|
| Specification issues | 41.77% |
| Inter-agent misalignment | 36.94% |
| Task verification | 21.30% |
Inter-agent misalignment — failures in how agents talk to each other — is more than a third of the total. Inside that bucket, the largest modes were mismatches between reasoning and action (13.98%) and proceeding with wrong assumptions instead of seeking clarification (11.65%), followed by task derailment (7.15%). The paper’s example of withholding crucial information is telling: a phone agent never passes an API’s username format requirement to its supervisor, and the supervisor never asks. Neither agent is “wrong” on its own. The handoff is.
The specification bucket matters here too. Context loss (3.33%) and failing to recognise task completion (9.82%) are both symptoms of a handoff that didn’t say clearly what was known and when to stop.
Anthropic’s engineering write-up on its multi-agent research system describes the same problem from the builder’s side. Early on, the lead agent gave subagents short instructions like “research the semiconductor shortage.” These were vague enough that subagents misread the task or repeated each other’s searches: one explored the 2021 automotive chip crisis while two others duplicated work on 2025 supply chains. Their fix was to make the brief richer: “Each subagent needs an objective, an output format, guidance on the tools and sources to use, and clear task boundaries.”
That sentence is effectively a schema. So write it down as one.
Two contracts per handoff
Every handoff has two directions, and each deserves its own type.
The brief (going down). What the receiving agent needs to start work: the objective, boundaries, inputs it can rely on, the tools or sources to use, and the expected output shape.
The result (coming back). What the caller needs to continue: the findings, how confident the agent is, what it couldn’t do, what it assumed, and where any large artefacts live.
Here’s a minimal version in Pydantic:
from pydantic import BaseModel, Field
from typing import Literal
class TaskBrief(BaseModel):
objective: str = Field(description="One sentence: what success looks like")
in_scope: list[str]
out_of_scope: list[str] = Field(description="Work other agents own — don't do it")
known_facts: list[str] = Field(description="Verified context the caller already has")
constraints: list[str] = Field(description="Formats, limits, policies to respect")
suggested_sources: list[str] = []
output_schema: str = "TaskResult"
budget_tool_calls: int = 15
class Finding(BaseModel):
claim: str
evidence_ref: str # URL, file path or record ID — not the raw content
confidence: Literal["high", "medium", "low"]
class TaskResult(BaseModel):
status: Literal["done", "partial", "blocked"]
findings: list[Finding]
assumptions: list[str] = Field(description="Things taken as true without checking")
open_questions: list[str] = Field(description="What the caller must answer or decide")
artifacts: list[str] = Field(description="References to stored outputs")
Each field maps to a known failure:
| Field | Failure it targets |
|---|---|
out_of_scope |
Duplicated work between parallel agents (Anthropic’s chip-shortage example) |
known_facts, constraints |
Withholding crucial information; context loss |
status, budget_tool_calls |
Failing to recognise completion; endless searching |
assumptions, open_questions |
Proceeding on wrong assumptions instead of asking |
evidence_ref, confidence |
Unverifiable claims the caller can’t check |
The assumptions and open_questions fields deserve special attention. A model that’s told to “just finish” will fill gaps silently. A schema with a required slot for assumptions makes the guess visible, so the caller (or a human) can catch it.
Pass references, not payloads
A typed summary is only half the story. The other half is not stuffing everything into it.
Anthropic describes having subagents write their outputs to a filesystem and “pass lightweight references back to the coordinator.” Their reasoning: this “prevents information loss during multi-stage processing and reduces token overhead from copying large outputs through conversation history.” They call the alternative a “game of telephone,” where each agent paraphrases the last one’s paraphrase. They note the approach works best for “structured outputs like code, reports, or data visualizations.”
In schema terms, that’s what evidence_ref and artifacts are for. The summary carries the conclusion and a pointer; the full content stays where it is, and the caller can load it only if it needs to. This is the same just-in-time idea we covered in context rot, applied between agents.
How frameworks expose this
You don’t need a framework to do any of this, but it helps to know what the tools give you. The OpenAI Agents SDK is a good example because its handoff model is explicit:
- Handoffs are tools. A handoff to an agent named “Refund Agent” shows up to the model as a tool called
transfer_to_refund_agent. input_typetypes the handoff call. You can give it a Pydantic model, and the SDK exposes it as the tool’s parameters, validates the JSON the model returns, and passes the parsed value to youron_handoffcallback. The docs suggest it for “a small piece of model-generated metadata such asreason,language,priority, orsummary.”- By default, the next agent sees everything. In the docs’ words: “it’s as though the new agent takes over the conversation, and gets to see the entire previous conversation history.”
input_filtercontrols what crosses. A filter receives the history and returns a new version; a built-inhandoff_filters.remove_all_toolsstrips tool-call items.
from pydantic import BaseModel
from agents import Agent, handoff, RunContextWrapper
from agents.extensions import handoff_filters
class EscalationData(BaseModel):
reason: str
priority: str
summary: str
async def on_handoff(ctx: RunContextWrapper[None], data: EscalationData):
log_escalation(data) # your own logging / checks
escalation_agent = Agent(name="Escalation agent")
to_escalation = handoff(
agent=escalation_agent,
input_type=EscalationData,
on_handoff=on_handoff,
input_filter=handoff_filters.remove_all_tools,
)
Two details from the docs are worth knowing. First, input_type “does not replace the next agent’s main input” — it’s metadata about the handoff, so if you want the receiving agent to work from a clean typed brief rather than the full history, you need a filter or a different pattern (the docs point to Agent.as_tool(parameters=...) for passing structured input to a specialist without transferring the conversation). Second, filters and the SDK’s history summarising “do not redact sensitive data.” Tool arguments copied into normal messages or summaries still travel. Treat the receiving agent and its model provider as recipients of whatever you forward.
Trade-offs
Structured handoffs aren’t free, and they aren’t a cure.
- Schemas compress, and compression loses things. A summary forces the sending agent to decide what matters. If the receiving agent needed the nuance in a raw tool output, a tidy
Findingwon’t have it. References are the escape hatch. - Too rigid, and agents game the form. If every field is required, models will fill them with filler (“no assumptions”) rather than leave them honest. Make the important fields required and check them in evals.
- Full history versus typed brief is a real choice. Full history keeps every implicit decision but bloats context and leaks tool noise. A typed brief is focused but can drop a decision nobody thought to write down. Many systems use a typed brief plus references to the full trace.
- Validation catches shape, not truth. A schema guarantees a
confidencefield exists, not that it’s calibrated. You still need verification — which the Cemri et al. paper found accounts for over a fifth of failures on its own. - It’s not the only lever. In the same paper, clearer role specifications alone gave ChatDev a +9.4% success-rate gain, and adding a high-level verification step gave +15.6% on their programming task. The authors also stress that their interventions didn’t eliminate failures. Handoff design is one part of a working system.
Where to start
- Log every handoff as its own event. Record what was sent and what came back. Most “the agents got confused” bugs are visible right there.
- Write a brief schema with objective, in-scope, out-of-scope, known facts, constraints and expected output. Have your orchestrator fill it instead of writing free text.
- Write a result schema with status, findings plus evidence references, assumptions and open questions. Reject or retry results that fail validation.
- Store large outputs outside the context and pass references. Let the caller load details on demand.
- Decide deliberately what history crosses. If your framework forwards the whole conversation by default, filter it — and remember that filtering is not redaction.
- Add evals at the seams. Check that briefs contain the facts the receiver needed, and that results surface their assumptions. Grade the handoff, not just the final answer.
Agents are getting better at doing work. The hard part is increasingly the space between them — and that space is something you can design.