Home/Blog/The Baton Pattern
All posts

The Baton Pattern

A lightweight handoff protocol for multi-agent AI pipelines. A small JSON object that carries context between workflow stages.

EngineeringFebruary 16, 20265 min
ByHamza Mounir· Co-Founder
AI AgentsDesign PatternsOrchestration

How the Baton Flows

01
>_
Planner
baton + patch
02
>_
Implementer
baton + patch
03
>_
Tester
baton + patch
04
>_
Reviewer
baton + patch
baton.json~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"]
}

A lightweight handoff protocol for multi-agent AI pipelines. A small JSON object that carries context between workflow stages.

How the baton flows

  1. 1.Planner → baton + patch
  2. 2.Implementer → baton + patch
  3. 3.Tester → baton + patch
  4. 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

FieldPurpose
goalOne-sentence objective
current_stateWhat's true right now
decision_logKey decisions made (append-only)
constraintsHard rules to respect
open_questionsUnresolved issues
work_scopeFiles/modules involved
artifactsReferences to produced outputs
acceptanceTests/checks that must pass

How It Works

  1. 1.Initialize: The baton begins with a goal and initial state
  2. 2.Inject: Before each stage, inject the baton into the agent's prompt as markdown
  3. 3.Patch: After executing, the agent returns a baton_patch—only changed fields update
  4. 4.Repeat: The updated baton feeds into the next stage until completion

Baton vs. Artifacts

AspectBatonArtifacts
Size~1,000 tokens1k–100k+ tokens
ContentDecisions, state, constraintsActual code, plans, docs
IncludedAlwaysSelectively
PurposeWhy and what mattersWhat 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_state reflects 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.