Messaging live coding agents without confusing delivery with completion

How a local MCP broker lets live Codex, Claude Code and hosted agent sessions message and wake each other, with journalled writes that never resend an unknown outcome.

October 20264 min readAgent systemsOrchestrationInterfacesAgent Switchboard

A narrow upright area of small sage touches stands on charcoal beside two ochre arcs, with one ivory mark at upper right.
On this page
  1. Peer controls and explicit capabilities
  2. Write-ahead dispatch and unknown outcomes
  3. Event-driven hand-offs without polling
  4. Verifying a four-agent chain

When you run several coding agents in parallel, context ends up scattered across live sessions. The Codex session that spent an afternoon on a parser holds the code, the decisions, and its permissions. Most orchestrators avoid that state by spawning fresh workers in their own runtime, which keeps isolation and cleanup straightforward. When you want a review from the session that already knows the codebase, though, spinning up a blank worker means burning tokens to rebuild context sitting in another window.

Connecting existing sessions instead turns every message into a non-idempotent write against a running agent, one that can start paid inference and modify files while a timeout says nothing about delivery. Handling that relies on standard distributed-systems primitives: a caller-supplied idempotency key, a write-ahead record, and an unknown outcome kept as state rather than resolved by resending. Beyond dispatch, the harder constraint is never letting five distinct facts stand in for one another: a transport ack, a queue receipt, a task completion, a webhook 200, and an agent actually finishing its work.

Agent Switchboard is a local Model Context Protocol (MCP) broker I built around those boundaries. It runs as a single Node process on my Mac with a private SQLite journal, letting Codex desktop, Claude Code, the agent platform I build at work, and the production coding agent my company ships list, read, message, and wake each other’s live sessions. Desktop clients reach it through small stdio shims over local IPC, which is why it lives on the Mac; the two hosted agents connect over HTTPS through an authenticated Cloudflare Tunnel.

Peer controls and explicit capabilities

Reliable receipts depend on strict identity and permission boundaries. Local adapters verify socket ownership and check each PID against its recorded start time, so a reused PID cannot impersonate a live session. Messages arrive as peer input governed by the recipient’s approval policy; the broker never copies permission modes across agents and never approves a held message. Delivery therefore confirms only that the recipient accepted the input under its own controls.

Capabilities follow the same constraint. Each provider advertises the exact operations it implements through a normalized interface, and unsupported operations remain unsupported. All four agents can list, read, and message sessions, while steering, stopping, creating, and archiving appear only where the provider supports them. Switchboard will not quietly substitute a new CLI worker for a desktop session it cannot create, because a stand-in holds neither the context nor the permissions the caller expected.

Write-ahead dispatch and unknown outcomes

Every write is committed to the SQLite journal under a caller-supplied request ID before dispatch. Replaying a request with the same ID and arguments returns the original receipt; reusing the ID with changed arguments returns a conflict. If a crash interrupts a write mid-flight, the record recovers into an unknown-outcome state and is never resent automatically, because auto-retrying an ambiguous call is how you pay twice to watch two turns collide over the same working tree.

A journal receipt still describes dispatch to the provider and nothing beyond it. When a call runs through MCP’s Tasks primitive, a completed task handle tells the caller only that the broker submitted the request; whether the agent did the work has to be read from its native status or transcript.

Event-driven hand-offs without polling

Hand-offs do not need polling. A watch follows one session’s lifecycle events, tailing desktop transcripts locally or consuming native streams from the hosted agents, into a bounded metadata journal with durable cursors and explicit gap markers. A follow rule translates matching events into a bounded number of notifications to another session, one by default, with expiry and no self-subscriptions. Callers avoid the race where a job completes before its listener exists by starting the watch first, capturing the cursor, dispatching the write with a stable request ID, and attaching the follow from that cursor.

Before notifying a target session, the broker reads its live status: it steers a busy session, starts a new turn on an idle one, and sends nothing if the state is unrecognized. Events carry metadata rather than transcript text, and a turn-ended boundary only means the model stopped talking, never that the requested work succeeded. Signed MCP event webhooks include cursors and replay protection without equating a 200 response to downstream completion, and elicitation routes provider questions to a human so no tool accepts another model’s reply as human authorization.

Verifying a four-agent chain

Across all four agents, every participant made live MCP calls to every provider, passing 16 of 16. To test the hand-off path end to end, I ran a four-hop chain starting from a real prompt in Codex desktop that messaged Claude Code. Claude Code’s turn end woke my company’s production coding agent, whose turn end woke my agent platform, whose turn end notified Codex again. Each notification was dispatched once and verified against the target’s native turn completion rather than broker receipts alone. Replaying the same signed webhook returned the original operation and dispatched nothing new.

Chris Chabot, October 2026