Case study · Open-Source AI Tooling
Agent Bridge
A public MIT-licensed, local-first coordination protocol for durable messaging, shared tasks, and bounded handoffs between terminal AI agents.
- Role
- Author & Systems Engineer
- Period
- 2026
- License
- Open-source · MIT
- Runtime
- Python standard library only
- No cloud, no hosted relayZero cloud service dependencies: it runs entirely offline and locally.
- Python standard library onlyRuntime dependencies stay within the Python standard library.
- Unix socket first, tmux only as fallbacktmux injection is explicit and optional, never the primary path.
- MIT licensedPublic on GitHub under a permissive license.
Four steps, in order
The recipient is listening before anything is sent. Verifying the work is its own step, recommended and not enforced by the bridge.
Before these steps, both runs (hermes-main and pi-worker) must be registered in the same database, with agent-bridge register or agent-bridge start. Listening to an unregistered run fails with run not found.
- Listener ready
agent-bridge listen pi-worker --onceThe recipient serves its inbox first. - Tell
agent-bridge tell --from hermes-main --to pi-worker --message '…'The message is stored, then delivered. - VerifyRecommended practice: the recipient checks the work itself. The bridge does not check it, and a socket reply only means the frame was accepted.
- Ack
agent-bridge ack <message-id> --run pi-workerOnly the recipient run can acknowledge, and only a delivered message. It records an acknowledgement, not proof of verification.
Delivery lifecycle
Every message is in exactly one state, and each state stays inspectable.
- queuedStored before delivery is attempted
- deliveredA transport accepted the frame: the Unix socket, or tmux for legacy runs
- acknowledgedRecipient acknowledgement recorded
- heldWaits for explicit approval. accept returns it to queued.
- refusedEnds delivery. It is recorded and never delivered.
- failedA distinct outcome that stays inspectable.
Handoff flow
- RegisterDurable Run IdentityA local process registers its run name, policy, and inbox address
- StoreSQLite Message QueueThe bounded message is persisted before delivery is attempted
- DeliverUnix Socket FirstA structured JSON frame is sent to the recipient's local inbox
- AcknowledgeExplicit OutcomeRecipient acknowledgement and delivery state remain inspectable
Conditional branch
Problem
Terminal-based AI agents and CLI copilots typically operate in isolated session silos. Passing state, sub-task delegations, and execution context between disparate agent runtimes required cumbersome manual copying or fragile temporary files.
System Architecture & Ownership
Designed a Python CLI and protocol with SQLite-backed messages and tasks, Unix-domain socket inbox delivery as the primary transport, and explicit tmux prompt injection as a fallback. Runs, policies, delivery states, acknowledgements, and task claims remain durable locally.
Constraints
- Zero cloud service dependencies—must run entirely offline and locally
- A structured primary transport with tmux available only as a compatibility fallback
- Python standard-library-only runtime dependencies
- Bounded messages, inboxes, retries, and explicit acknowledgement states
Engineering Decisions
- Used SQLite for the durable queue and atomic task claims instead of introducing a hosted relay.
- Made Unix-domain sockets the structured primary delivery path and kept tmux injection explicit and optional.
- Published under the permissive MIT license on GitHub to foster community adoption and extensible tooling integration.
- Kept runtime dependencies within the Python standard library.
Reliability
- Messages are stored before delivery and claimed atomically so concurrent workers cannot inject the same message twice.
- Each sender's retries are safe to repeat (idempotent), and caps on message size, inbox depth, send rate, and reply chains stop agents from looping.
- Queued, held, delivered, acknowledged, failed, and refused outcomes remain distinct and inspectable.
- Python
- SQLite
- Unix Domain Sockets
- Local-First Architecture
- IPC / Session Handoff
- MIT License
Evidence
Published as an open-source public repository on GitHub (github.com/oliveralerubio/agent-bridge) with complete test suites and documentation.
Created a vendor-neutral local coordination layer that lets independent agent processes exchange bounded work without a cloud database or hosted relay.
Reflection
The implementation showed that SQLite plus local sockets can provide durable, inspectable coordination while keeping provider-specific adapters outside the core protocol.
Need a similar automation system?
Let's review your operational bottlenecks and design a reliable production pipeline.