SHARED MEMORY · statefulai Claude Code drafts the implementation reads · writes Codex CLI reviews against the graph reads · annotates Cursor finalizes & merges reads · writes
A single ticket, three turns

Refactor billing.ts to use Stripe's usage API.

Same ticket, three agents, one shared memory. Each turn reads from the memory the previous turn wrote.

CLAUDEdrafts
Plan. Replace internal usage counter with StripeUsageClient.record(). Wrap in per-invoice lock; emit BillingFlushed on success. Drafted 3 files, 84 lines.
▸ ADR-014▸ BillingService graph▸ rule: @idempotent-writes
▸ wrote: episodic event · "claude · draft · 3 files · 84 LOC" + diff summary
CODEXreviews
Review. Read Claude's draft from memory, traversed graph for new dependencies. Found: missing zod validation on Stripe response. Annotated diff with 1 blocking comment, 2 nits. Suggested fix is 6-line patch.
▸ Claude's draft event▸ StripeUsageClient contract▸ rule: @zod-on-boundary
▸ wrote: episodic event · "codex · review · 1 blocking, 2 nits"
CURSORmerges
Finalize. Read both prior turns. Applied Codex's patch to Claude's draft, ran pnpm typecheck and pnpm test --filter billing. All green. Opened PR with the merged diff and a single-paragraph rationale citing ADR-014.
▸ both prior turns▸ rule: @pnpm-typecheck-pre-commit
▸ wrote: episodic event · "cursor · PR #482 opened · ready for human"
Total handoff tokens: 312. Without Statefulai, the same workflow on the same ticket spent ~4.1k tokens per handoff re-introducing the diff, the constraints, and the rules. That's a 92% reduction — three times.
Why it works

The protocol, not the prompt.

Three guarantees make multi-agent handoffs trustworthy.

01 · contract

Every turn is an event

Every agent action writes a structured event to episodic memory: who, what, when, files touched, decision rationale. The next agent reads the event, not the chat log.

02 · scope

Branch-scoped reads

Agent 2 retrieves with the same branch filter as Agent 1. Cross-branch leakage doesn't happen by accident — you have to opt in.

03 · audit

Citation is mandatory

Every memory the agent uses is cited in its output. Humans (or other agents) can verify the chain of reasoning across the handoff.

tokens / handoff
−92%
vs cold prompt
handoff latency
12ms
retrieval p50
conflicting diffs
−68%
caught at review turn
human review time
−41%
per PR
Multi-agent · unified

Let your agents talk to each other.

Get early accessRead the docs