agentbridge
agentbridge is a general-purpose agent adapter library. It bridges any agent
that speaks the CliAdapter trait or the agentbridge JSON subprocess protocol
into the shadi_mas coordination runtime so they can exchange context, delegate
tasks, and coordinate autonomously toward a shared goal.
Today's built-in adapters target CLI coding tools (Claude Code, GitHub
Copilot, OpenAI Codex, Cursor Agent) since interconnecting coding assistants
was the motivating use case this was first built for, and they remain the
flagship example below — but nothing in CliAdapter or the coordination
runtime is specific to coding tools.
How it fits into SHADI
CLI tools agentbridge adapters shadi_mas engine
────────────── ───────────────────── ─────────────────────────────
Claude Code ──► ProfileAdapter ──►
Copilot CLI ──► (profiles/*.json) ──►
Codex CLI ──► ──► MasRuntime<DevelopmentEngine>
Cursor Agent ──► ──►
any CLI ──► GenericStdioAdapter ──►
│ │
│ ContextPacket │ A2A / SLIM / DIR
│ (handoff / relay) │ (transport / discovery)
Core types
CliAdapter (trait)
The central abstraction. A new coding CLI is a JSON profile under
profiles/ (ProfileAdapter). Implement this trait only for a protocol
that is not argv-driven (for example GenericStdioAdapter).
ContextPacket
A portable, serializable snapshot of a coding session: conversation history, code files, git diff, and generated artifacts. Used for context handoff between tools and for persistence across sessions.
Serializes to/from JSON:
let pkt = new;
let bytes = pkt.to_bytes?;
let restored = from_bytes?;
CliToolAdapter<A> (wrapper)
Bridges any CliAdapter into shadi_mas::ToolAdapter so it can participate
directly in MasRuntime<DevelopmentEngine> coordination rounds.
let inner = new;
let tool_adapter = new;
// tool_adapter now implements shadi_mas::ToolAdapter
Subprocess protocol (GenericStdioAdapter)
GenericStdioAdapter spawns a subprocess and communicates via newline-delimited
JSON on stdin/stdout. Any process that speaks this protocol becomes a agentbridge
participant with no code changes:
Requests (agentbridge → subprocess stdin):
Responses (subprocess stdout → agentbridge):
Spawn an adapter:
let adapter = spawn?;
Implementing a custom adapter
use ;
use AgentId;
Crate features
This crate ships with zero optional features. All heavy infrastructure
(shadi_mas coordination, A2A, SLIM) is brought in at the agentbridge_cli
binary level so the library stays lightweight.