Multi-agent handoff patterns that don't lose context

multi-agent orchestration patterns
TL;DR
  • Context loss at handoff boundaries is the #1 multi-agent failure mode
  • Pattern 1: Context envelope — structured handoff carrying task lineage
  • Pattern 2: Shared scratchpad — agents observe and build on each other's work
  • Pattern 3: Supervisor with replay — higher cost, zero context loss

The multi-agent dream: a planner agent decomposes the task, a researcher gathers data, a coder writes the implementation, a reviewer catches bugs. Reality: the coder has no idea what the planner intended because context was lost at the handoff.

Pattern 1: context envelope

Wrap every handoff in a structured envelope that carries task context, constraints, and lineage. The receiving agent doesn’t just get “write code” — it gets the full decision tree that led to this moment.

envelope = HandoffEnvelope(
    task="implement flight search API",
    origin="planner",
    context={
        "constraints": ["must use MCP", "latency < 2s"],
        "prior_research": researcher.summary(),
        "decision_log": planner.decisions()
    }
)

Pattern 2: shared scratchpad

All agents read and write to a shared memory space. No handoffs needed — agents observe what other agents have produced and build on it. Works best for collaborative tasks where agents work in parallel.

Pattern 3: supervisor with replay

A supervisor agent maintains the full execution trace and replays relevant context to each worker agent. Higher token cost, but zero context loss. The supervisor acts as an intelligent context window manager for the entire swarm.

Agent Trace

agent trace · post #2 8 steps · 7.4s
THINK Task requires 3 agents. Initializing handoff chain. 3ms
TOOL planner.decompose('build flight booking feature') 420ms
OBS 3 subtasks: [research, implement, review] 2ms
ACT HandoffEnvelope created. Passing to researcher. 5ms
TOOL researcher.run(envelope) 2.8s
ACT Research complete. Enriching envelope, passing to coder. 8ms
TOOL coder.run(enriched_envelope) 4.2s
ACT Implementation ready. Final handoff to reviewer. 3ms
Open in terminal ↗