Agent-to-Agent Handoffs & Shared State

Claude Code Agents: Advanced Orchestration

Chapter 7 · Agent-to-Agent Handoffs & Shared State

Chapter 1 of this course warned that Fundamentals' own "an agent starts cold" problem compounds across a chain — each handoff is a fresh opportunity for context to get lost. This chapter covers the actual mechanics of doing a handoff well, and why a long chain often needs more than just passing results from one step to the next.

What a Handoff Actually Requires

Fundamentals' Chapter 3 established what a good brief needs: the goal, known context, constraints, and the expected form of the result. A handoff between two agents is really the same thing, except the "known context" section is populated automatically from the prior agent's own final report, rather than written by a human from scratch. The job of designing a good handoff is making sure that automatic transfer actually carries forward everything the next agent genuinely needs — the same standard a well-written human brief would meet.

Passing a Full Report vs. a Distilled Summary

There's a real design choice in how much of a prior agent's output to hand to the next one. Passing the full report verbatim preserves everything, at the cost of length and noise — echoing Fundamentals' own point that unfiltered exploratory detail clutters a context without adding proportional value. Passing a distilled summary is cleaner, but introduces a real risk: whoever (or whatever) does the distilling might drop something the next agent actually needed, simply because it didn't look important at the time.

Shared State Beyond a Single Handoff

In a chain longer than two agents, a pure point-to-point handoff — where each agent only ever sees the immediately preceding agent's output — has a real limitation: something stated once at the very start of the chain (an original constraint, for instance) can silently disappear a couple of hops downstream if each successive summary only distills forward what the immediately prior step itself covered. A shared state — a running document or object carried alongside the chain, not just handed step to step — solves this by keeping information that matters for the whole chain visible throughout it, not just to whichever agent happened to receive it most recently.

A Worked Example

Consider a research agent, feeding a planning agent, feeding a coding agent — the same shape as this course's own Chapter 11 capstone. Suppose the original task states a hard constraint from Fundamentals' own Chapter 8 example: the public API signatures must not change. If that constraint is only ever passed forward as part of each step's own distilled summary, there's a real risk it gets quietly dropped by the second hop — the planning agent might mention it, but a summary of the planning agent's own output handed to the coding agent might not repeat it explicitly. Carrying that constraint in a shared state document, visible to every agent in the chain regardless of how many hops have happened, guarantees the coding agent still sees it at the very end, not just the step immediately after it was first stated.

AspectPoint-to-Point HandoffShared State
What persistsOnly what the immediately prior step's own output includedAnything deliberately added, visible to every later step
RiskSomething stated early can silently drop after a few hopsCan grow unmanaged if everything gets added indiscriminately
Best suited forShort chains, two or three stepsLonger chains where early constraints must stay visible throughout
Carry the original task's hard constraints explicitly, not just each step's output
The original task's own genuine constraints — things that must or must not happen, stated once at the start — are exactly the kind of information that silently drops out after a couple of hops in a pure point-to-point chain. Add them to shared state explicitly and keep them visible for the whole chain, rather than trusting each successive summary to keep repeating them on its own.
Shared state can recreate the same bloat problem, one level removed
Dumping everything from every step into shared state indiscriminately just moves Fundamentals' own "exploratory noise clutters context" problem from a human's conversation into an agent chain's own shared state, rather than actually solving it. The real skill is deliberately choosing what's genuinely worth carrying forward — the original constraints, key decisions actually made — versus what was just one step's own disposable working detail that later steps don't actually need.

Hands-On Exercises

Exercise 1

Explain the trade-off between passing a prior agent's full report versus a distilled summary to the next agent in a chain.

📄 View solution
Exercise 2

A four-agent chain relies purely on point-to-point handoffs, with no shared state. A constraint stated at the very start doesn't appear anywhere in the fourth agent's own brief. Explain why this happened, using this chapter's own material.

📄 View solution
Exercise 3

A team, having learned about shared state, decides to add every single detail from every agent's output into it, reasoning "more shared context can only help." Using this chapter's own warning box, explain what's wrong with this approach.

📄 View solution

Chapter 7 Quick Reference

  • A handoff is the same brief-writing skill from Fundamentals Ch.3, populated automatically from the prior agent's own report
  • Full report: nothing lost, but noisy. Distilled summary: cleaner, but risks dropping something needed
  • Shared state keeps information relevant to the whole chain visible throughout — not just to the immediately next step
  • Carry original hard constraints explicitly in shared state — they're exactly what silently drops after a few hops otherwise
  • Indiscriminately dumping everything into shared state just recreates the same context-bloat problem one level removed