A lightweight handoff protocol for multi-agent AI pipelines. A small JSON object that carries context between workflow stages.
How the baton flows
- 1.Planner → baton + patch
- 2.Implementer → baton + patch
- 3.Tester → baton + patch
- 4.Reviewer → baton + patch
Example Structure (~1,000 tokens)
{
"goal": "Add user auth",
"current_state": ["Routes created", "Tests passing"],
"decision_log": ["Chose JWT over sessions"],
"constraints": ["No breaking changes"],
"work_scope": ["src/auth/*"],
"artifacts": [],
"open_questions": [],
"acceptance": ["All auth tests green"]
}The Problem
When multiple AI agents collaborate sequentially—planning, building, and reviewing—they struggle with context transfer. Key challenges include:
- >Passing full artifacts (code, docs) between every stage costs too many tokens
- >Even with complete artifacts, agents overlook the reasoning behind decisions
Without structured handoffs, agents duplicate effort or contradict prior choices.
The Solution
The baton is a small JSON object (~1,000 tokens) that travels between stages. Each agent reads it before starting and patches it upon completion—similar to a relay race baton carrying notes.
Structure
| Field | Purpose |
|---|---|
goal | One-sentence objective |
current_state | What's true right now |
decision_log | Key decisions made (append-only) |
constraints | Hard rules to respect |
open_questions | Unresolved issues |
work_scope | Files/modules involved |
artifacts | References to produced outputs |
acceptance | Tests/checks that must pass |
How It Works
- 1.Initialize: The baton begins with a goal and initial state
- 2.Inject: Before each stage, inject the baton into the agent's prompt as markdown
- 3.Patch: After executing, the agent returns a
baton_patch—only changed fields update - 4.Repeat: The updated baton feeds into the next stage until completion
Baton vs. Artifacts
| Aspect | Baton | Artifacts |
|---|---|---|
| Size | ~1,000 tokens | 1k–100k+ tokens |
| Content | Decisions, state, constraints | Actual code, plans, docs |
| Included | Always | Selectively |
| Purpose | Why and what matters | What was produced |
The baton communicates "what happened and why," while artifacts represent the actual work product.
Key Design Choices
- >Append-only decisions: Earlier decisions persist, preventing contradictions
- >Replace semantics for state:
current_statereflects current truth, not history - >Budget-friendly: At ~1,000 tokens, the baton always fits in context
- >Full audit trail: Every patch records timestamp and stage ID
When to Use This
The baton pattern suits any multi-step AI pipeline where:
- >Agents need context from previous steps
- >Token budgets are limited
- >Decisions must remain consistent across stages
- >Context evolution requires tracing
It maintains intentional simplicity—just a JSON object with merge-patch updates.
Ready to build with AI agents?
See the Baton Pattern in action inside a Pixl sandbox.