Pixl
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
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"]
}

The Problem

When multiple AI agents work together in a pipeline — one plans, another builds, another reviews — they need context from each other. But:

  • >Passing full artifacts (code, docs) between every stage costs too many tokens
  • >Even with full artifacts, agents miss the why — the decisions and constraints behind the work

Without a structured handoff, agents repeat work or contradict earlier decisions.


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 when done.

Think of it like a relay race baton — except this one carries 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. Initialize

The baton starts with a goal and an initial state.

2. Inject

Before each stage, the baton is injected into the agent's prompt as markdown.

3. Patch

After executing, the agent returns a baton_patch — only the fields that changed get updated.

4. Repeat

The updated baton feeds into the next stage until the workflow completes.


Baton vs. Artifacts

BatonArtifacts
Size~1,000 tokens1k–100k+ tokens
ContentDecisions, state, constraintsActual code, plans, docs
IncludedAlwaysSelectively
PurposeWhy and what mattersWhat was produced

The baton tells the next agent what happened and why. Artifacts are the actual work product.


Key Design Choices

Append-only decisions. Earlier decisions are never erased. This prevents contradictions.

Replace semantics for state. current_state is replaced each time — it reflects current truth, not history.

Budget-friendly. At ~1,000 tokens, the baton always fits in context.

Full audit trail. Every patch is recorded with timestamp and stage ID.


When to Use This

The baton pattern works for any multi-step AI pipeline where:

  • >Agents need context from previous steps
  • >Token budgets are limited
  • >Decisions must be consistent across stages
  • >You need to trace how context evolved

It's intentionally simple — just a JSON object with merge-patch updates.

Want to discuss multi-agent patterns?

We love talking about orchestration, AI workflows, and engineering challenges.

CONTACT.exe

> Initializing contact module...

> ..._

Have a custom project in mind? Want to build something unique for your business? Send us a message and we'll get back to you.