Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
When one agent hands work to another, the hand-off payload is a context-engineering artifact. Pass too little and the next agent lacks what it needs; pass the entire history and you've recreated the shared-context blob. A clean hand-off is a deliberately-shaped briefing: the goal, the relevant findings, the decisions made, the open questions — not the raw transcript. Designing hand-off schemas is what makes agent pipelines composable, debuggable, and cheap. It's the multi-agent analogue of a good function signature.
The demo defines a typed hand-off payload that the upstream agent fills and the downstream agent consumes — a contract, not a transcript dump. The structure forces the upstream agent to distill rather than forward everything.
Use these three in order. Each builds on the one before.
What is a context hand-off between agents, and why shouldn't I just pass the whole conversation history?
Explain how a typed hand-off payload (goal/findings/decisions/open-questions) makes agent pipelines composable and cheap compared to forwarding transcripts.
Design hand-off schemas for a multi-stage agent pipeline so each stage gets exactly what it needs. How do I version these schemas and validate hand-offs to catch coordination bugs early?
from dataclasses import dataclass, field
@dataclass
class HandOff:
goal: str
findings: list[str]
decisions: list[str]
open_questions: list[str]
# deliberately NO 'full_transcript' field — distill, don't forward
def research_agent(task) -> HandOff:
return HandOff(
goal=task,
findings=["Supply delay risk is high", "FX exposure is moderate"],
decisions=["Focus the report on supply chain"],
open_questions=["Is the FX hedge still active?"],
)
def writer_agent(h: HandOff) -> str:
qs = ("; ".join(h.open_questions)) or "none"
return f"GOAL: {h.goal}\nWRITE-UP based on: {h.findings}\nFlagging open: {qs}"
print(writer_agent(research_agent("Summarize Q2 risks")))python3 main.py