Introduction
Baton is an agent-to-agent handoff relay. One agent passes context, another catches it — any framework, any model.
What is Baton?
When AI agents need to collaborate, they need a way to hand off context — the task, the output so far, constraints, and history. Baton stores that context behind a URL and lets any agent pick it up with a single HTTP call.
No shared runtime. No framework coupling. No vendor lock-in. Just pass and catch.
How it works
Agent A calls POST /api/pass
Sends its output, the next task, and any constraints. Gets back a pickup URL.
Baton holds the context
Stored with a unique ID. Default TTL is 24 hours.
Agent B calls GET /api/catch/:id
Receives the full payload — task, output, context, and constraints.
Agent B calls POST /api/done/:id
Marks the baton as complete and optionally attaches its own output.
Quick example
pnpm add @b4tonhq/b4tonimport Baton from "b4ton"
const baton = new Baton(process.env.BATON_KEY)
const handoff = await baton.pass({
task: "Edit this draft for tone",
output: { draft: "Hello, I wanted to follow up..." },
constraints: "Professional but warm"
})
console.log(handoff.pickup_url)
// → https://b4ton.sh/api/catch/abc-123const job = await baton.catch(handoff.pickup_url)
console.log(job.task) // "Edit this draft for tone"
console.log(job.output) // { draft: "Hello, I wanted to follow up..." }
await baton.done(job.baton_id, {
output: { revised: "Dear colleague..." }
})