# agentbridge — General-Purpose Agent Interconnect over A2A agentbridge bridges agents over the [A2A protocol](slim_a2a.md) — via a pluggable A2A transport (SLIMRPC or standard gRPC), DID identity, DIR discovery, and `agentbridge_mas` for autonomous multi-round coordination — so they can exchange context, delegate tasks to each other, and coordinate autonomously toward a shared goal. Nothing in that mechanism is specific to any one kind of agent: any agent that speaks A2A, or the simpler agentbridge subprocess protocol (`GenericStdioAdapter`), can be bridged this way. Today's built-in adapters happen to target CLI coding tools — Claude Code, GitHub Copilot CLI, OpenAI Codex CLI, Cursor Agent — because interconnecting coding assistants was the motivating use case this was first built for, and they remain the flagship, most-exercised example throughout this page and the demos. The `CliAdapter` trait, the A2A/SLIM transport, and the coordination runtime underneath them don't know or care that they're wrapping coding tools; a bridge for any other class of agent looks the same. ## Motivation The concrete problem that motivated agentbridge: every major coding assistant operates in isolation. When a developer switches tools (e.g., from Claude Code to Copilot), all conversation history, open files, and accumulated context is lost. There was no standard way to: - Hand off an in-progress session from one tool to another, - Ask one agent to generate a specific artifact for another agent's task, or - Have multiple agents propose solutions and converge on the best one without human mediation. agentbridge solves this with A2A for task delegation, SLIMRPC or gRPC for transport, DIR for discovery, and `agentbridge_mas` for autonomous multi-round coordination — the same general-purpose stack that would bridge any other kind of agent, applied here to coding tools first. Identity comes from [polis](https://github.com/agntcy/polis); confinement, when you want it, from [shadi](https://github.com/agntcy/shadi) or any other sandbox. ## Quick start Install the CLI ([Install the CLI](install.md)), then run the [DID agent-group demo](demos/did-agent-group.md) from a clone of the repository: ```bash bash docs/content/demos/run-demo.sh ``` It forms a SLIM group of DID-identified agents, has them exchange an A2A roll call and, with `shadictl` installed, delegates real tasks to the coding CLIs on your machine. [Getting Started](getting_started.md) walks through the rest. ## Architecture ### Deployment topology `register` and `coordinate` run on separate hosts (or separate terminals on the same machine). Unicast A2A can use a SLIM node (`--slim-endpoint`) or official A2A unicast (`--a2a-listen` / `--a2a-binding` / `delegate --a2a-url`) without one. `handoff` and `coordinate` stay on SLIM in this slice. Identity is always the application DID on the message, not the URL. Address a peer by that DID; look up the current gRPC URL or SLIM name when it moves. ```mermaid flowchart LR subgraph reg["agentbridge register (one per agent)"] direction TB tool["CLI tool\ngeneric-stdio | claude-code | copilot | codex | cursor-agent | goose | opencode"] ca["CliAdapter\nexecute_prompt(prompt) → text"] srv["A2A server\nAgentBridgeRequestHandler\nInMemoryTaskStore"] tool -- "stdin / stdout" --> ca --> srv end slim{{"SLIM node\nagntcy/shadi/<key>-a2a\nmTLS · DID auth"}} subgraph coord["agentbridge coordinate"] direction TB mas["MasRuntime<DevelopmentEngine>\nproposal → vote → finalize"] sta["SlimToolAdapter\n(one per --agents spec)"] laa["LiveA2ATaskAdapter\nSLIMRPC dispatch"] mas --> sta --> laa end srv <-- "A2A tasks (text/plain)" --> slim slim <-- "A2A tasks (text/plain)" --> laa ``` `register --tool` accepts `generic-stdio` or a bundled profile id (`claude-code`, `copilot`, `codex`, `cursor-agent`, `goose`, `opencode`). After a listener starts, `agentbridge list --local` shows it (name, DID, `slim://…` and/or `http://…`) from the lease file under `$AGENTBRIDGE_TMP_DIR`. `goose` and `opencode` keep their own provider config (`~/.config/goose`, `~/.config/opencode`). Agentbridge does not set a base URL or API key. When `GOOSE_PROVIDER` / `GOOSE_MODEL` are set in the host environment, the goose listener passes them as `goose run --provider` / `--model`. Host `GOOSE_*`, `OPENAI_*`, `*_API_KEY`, and `api_key_env` names from the operator's Goose provider files are copied onto that process. Extra flags: `GOOSE_ARGS` / `OPENCODE_ARGS`. Outbound A2A text is wrapped in a DID-proof envelope. Unsigned inbound parks as `AUTH_REQUIRED` (re-prove / ask / deny); a forged DID is rejected. ### Coordination loop `coordinate --pattern development` (default) is CONVERGE for a **code** class: every agent proposes a code artifact, then every agent votes on the best one. Once every agent has voted, the most endorsed artifact wins if it has `--quorum` endorsements. Otherwise the round is repeated, and the last round (`--max-rounds`) takes the most endorsed artifact. A vote that fails or names no proposal counts as an abstention. The same two group phases cover any class. `--assembly` asks the team to model the problem first. `--pattern preference|cascade|resource` runs CONVERGE on a paper engine. See [ASSEMBLY and CONVERGE](assembly-converge.md). ```mermaid sequenceDiagram participant MAS as DevelopmentEngine participant CO as coordinator participant A as copilot (SLIM) participant B as codex (SLIM) rect rgb(240,248,255) note right of CO: epoch 0 — proposal phase CO->>A: proposal prompt (goal, epoch 0) A-->>CO: code artifact CO->>B: proposal prompt (goal, epoch 0) B-->>CO: code artifact CO->>MAS: apply ExternalBytes(copilot_code) CO->>MAS: apply ExternalBytes(codex_code) end rect rgb(240,255,240) note right of CO: epoch 0 — vote phase CO->>A: vote prompt (goal + both proposals) A-->>CO: endorses copilot CO->>B: vote prompt (goal + both proposals) B-->>CO: endorses copilot CO->>MAS: apply ToolResult{copilot, accepted:true} (copilot's ballot) CO->>MAS: apply ToolResult{copilot, accepted:true} (codex's ballot) note over MAS: every agent has voted, quorum met MAS-->>CO: Finalized — winner: copilot (2/2 votes) end CO->>CO: write artifact → output.rs ``` ### A2A task flow inside a registered adapter How one incoming task travels from the SLIM node down to the wrapped CLI tool and back: ```mermaid sequenceDiagram participant CO as coordinator participant SL as SLIM node participant SV as AgentBridgeRequestHandler participant EX as AgentBridgeExecutor participant AD as CliAdapter CO->>SL: SendMessage(DID-proof envelope) SL->>SV: SLIMRPC frame SV->>SV: unwrap DID-proof (unsigned → AUTH_REQUIRED, forged → Rejected) SV->>EX: execute(context) EX->>EX: strip "body:\n" envelope header EX->>AD: execute_prompt(prompt) AD->>AD: invoke CLI tool (subprocess / API) AD-->>EX: response text EX-->>SV: StatusUpdate(Working) EX-->>SV: Task{Completed, message: response_text} SV-->>SL: stream response SL-->>CO: Task{Completed} ``` ## Use from a harness Coding harnesses (Claude Code, Cursor, Copilot, Codex) should **call the `agentbridge` CLI**, not speak SLIMRPC themselves. Install the skill pack by copying [`skills/agentbridge/`](https://github.com/agntcy/agentbridge/tree/main/skills/agentbridge) to the host skills directory (folder name must be `agentbridge`): | Host | Destination | |---|---| | Claude Code | `~/.claude/skills/agentbridge/` or `.claude/skills/agentbridge/` | | Cursor | `.cursor/skills/agentbridge/` | | GitHub Copilot | `~/.copilot/skills/agentbridge/` | | Codex / others | that host’s skills directory, same folder name | The skill only documents existing flags: `list --local`, `delegate`, `handoff --from slim:… --to slim:…`. Source [demo-env.sh](demos/demo-env.sh) so DID auth is set. A fifth CLI on the **register** side is a JSON profile under `crates/agentbridge/profiles/`, not a new Rust adapter. ASSEMBLY / CONVERGE hops load [`skills/assembly`](https://github.com/agntcy/agentbridge/blob/main/skills/assembly/SKILL.md) and [`skills/converge`](https://github.com/agntcy/agentbridge/blob/main/skills/converge/SKILL.md) the same way. Do not paste those files into `--text`. See [ASSEMBLY and CONVERGE](assembly-converge.md#agent-skills). ## Three interaction models ### 1. Context handoff Export a session snapshot from one tool and import it into another. The `ContextPacket` carries conversation history, open files, git diff, and any generated artifacts. ```bash agentbridge handoff --from claude-code --to copilot SHADI_AGENT_ID=claude-code agentbridge handoff \ --from slim:claude-code --to slim:copilot --slim-endpoint 127.0.0.1:47591 ``` `--from` / `--to` accept the same specs as `coordinate` (`claude-code`, `copilot`, `codex`, `cursor-agent`, `goose`, `opencode`, `generic-stdio:`, `slim:`). A bare subprocess command still opens GenericStdio. `--save` / `--from-file` persist the packet. Bare tool names open a **local** `CliAdapter` (`snapshot_context` / `inject_context`). `slim:` is A2A: `LiveA2ATaskAdapter` proves as `SHADI_AGENT_ID` and `SendMessage`s to ``'s listener, named after the DID in its lease. When `SHADI_AGENT_ID` matches `--from slim:`, the source is that agent acting as an A2A *client* — snapshot stays local so the process does not call its own listener; only the destination inject is an A2A task. The [round-robin Rust demo](demos/collab-rust.md) does not call `handoff` from `avatar`. After a coding turn the `register` listener reads `NEXT ` and dispatches that inject itself (`AGENTBRIDGE_A2A_FORWARD=1`). The snapshot is an LLM summary of the source session this cycle, not a true session export (except the self-`slim:` case, which is a short local note). 1. Source → `ContextPacket` (local snapshot, or A2A summary if `avatar` reads a remote `slim:` peer) 2. Optional `--save` of the packet 3. Destination → `inject_context` (local) or A2A inject prompt (`slim:`) ### 2. Task delegation One tool commissions a specific subtask to another and retrieves the artifact. ```bash agentbridge delegate --to codex "write unit tests for src/parser.rs" ``` For follow-ups, pass the same `--context-id` on each call to the same listener. If omitted, AgentBridge derives a peer-specific context ID from the first nonblank `IOC_SESSION_ID`, `CLAUDE_CODE_SESSION_ID`, `CODEX_THREAD_ID`, or `CODEX_SESSION_ID` without sending that value to the peer. Use `--context-id=` to start an independent task even when one of those variables is set. The listener resumes its own harness session; it does not import the caller's transcript. For resumable Codex delegation, register a `codex-isolated` listener. It stores transcripts under its own Codex home. The plain `codex` profile runs with `--ephemeral` and does not resume delegated sessions. Implemented via `LiveA2ATaskAdapter::dispatch()` from `agentbridge_mas`. The result is an A2A artifact containing the generated code. ### 3. Autonomous multi-round coordination ```bash agentbridge coordinate \ --goal "implement a JSON parser" \ --agents claude-code,copilot,codex,cursor-agent \ --quorum 3 ``` 1. `MasRuntime` is instantiated with all four adapters. 2. Each agent invokes its CLI tool via `ToolAdapter::call()` → code proposal. 3. Proposals are published to a SLIM group session. 4. Agents vote via `SemanticPayload::ToolResult { accepted: true }`. 5. Once every agent has voted, the most endorsed artifact with at least `--quorum` endorsements → `EventOutcome::Finalized` → loop exits. Without one the round is repeated; the last takes the most endorsed. 6. The winning artifact is written to disk. Human approval is optional. ## Asking a channel's owner A channel's owner is a human DID, and the owner's policy decides who may join (agntcy/shadi#420). An agent asks it over A2A: ```bash agentbridge request-invite --owner agntcy/shadi/avatar \ --channel agntcy/shadi/review-room \ --invitee-name agntcy/shadi/copilot --invitee-did did:key:z6Mk... ``` The request is a `SHADI-CHANNEL-REQUEST/1` body, signed with the agent's DID like any task, and goes to the owner's `-owner` service. The owner's standing rules (`agentbridge::owner`) decide it: ```json { "default": "ask", "ask_timeout_seconds": 300, "grant_seconds": 3600, "rules": [ { "channel": "*", "requested_by": "did:key:z6MkMyAgent", "decision": "allow" }, { "channel": "agntcy/shadi/review-room", "invitee": "did:key:z6MkStranger", "decision": "block" } ] } ``` The first rule that matches decides. If none matches, `default` decides. - `allow` signs a `SLIM-CHANNEL-GRANT/1`, and the owner invites the invitee. - `block` refuses the request. - `ask` holds the request for the owner. An ask nobody answers is denied when it times out. A rule can also match `requested_by_human`: the human named by the binding a sender attaches, if it attaches one. A channel manager also asks the owner about removals; a rule decides those only if it says `"action": "delete"`, and a rule without an `action` decides only additions. Every decision is appended to the owner's audit log. The agent gets a one-line reply: `granted: ...`, `pending: ...` or `refused: ...`. ## A2A server — how `register` exposes an adapter When `agentbridge register` is called with `--slim-endpoint` and/or `--a2a-listen`, it starts a full A2A server that makes the local adapter reachable to peers on that binding. Both paths share `AgentBridgeRequestHandler` and the same DID-proof admission. `--a2a-listen host:port` plus `--a2a-binding grpc|jsonrpc|http+json` serves one official A2A binding (default `grpc` → `lf.a2a.v1.A2aService`). The DID is the portable name (aliases: tool name, SLIM channel `agntcy/shadi/-a2a`). The locator is the local SLIM node (`slim://host:port`) and/or a unicast `{binding, url}`, looked up from the lease or DIR. Loopback (`127.0.0.1`, `::1`) may be plaintext HTTP. Any other bind, including `0.0.0.0`, requires TLS 1.3 from `A2A_TLS_CERT` / `A2A_TLS_KEY` (or `$AGENTBRIDGE_TMP_DIR/shadi-a2a-tls/{server.crt,server.key}`). Do not reuse `SLIM_TLS_*`. Verify operator-supplied certificates with `openssl x509 -text -noout -in ` before use (expiration, RSA ≥ 2048 or P-256+, SHA-2 signatures; self-signed only for lab). `https://` **gRPC** client TLS is not wired (a2aproject/a2a-rs#162); JSON-RPC and HTTP+JSON clients use reqwest and can speak HTTPS. ### SLIM address Each adapter registers under a name derived from its DID: ```text agntcy/shadi/-a2a ``` `` is the agent's `did:key` without `did:key:`, so two people's `copilot` get different names, and whoever holds the DID can address the listener: `delegate --to did:key:…` sends there on the configured endpoint when the Agent Directory answers that it has no record of the DID (a failed lookup is still reported). A caller sends to the name a peer advertises in its card, dir-runtime entry or local lease, so `--agents slim:copilot` uses the name in `copilot`'s lease. For an agent on another host, use its DID: `--agents slim:did:key:…@`. `` is the agent's name, which is also its card and workload name, its local lease, the name `delegate --to` takes and, with `SLIM_HUMAN_SEED`, the source of its DID. It is: - `--name ` when given (ASCII letters, digits, `-` and `_`, at most 64); - else, with `--record`, `-`, so `--tool claude-code-isolated --record code-review` is `code-review-claude-code-isolated`. A record name with characters SLIM can't hold has each run of them turned into `-` and gains an 8-character digest of the original name, so `org/skill` and `org-skill` stay apart. A record name too long to fit keeps its start and gains the same digest; with a profile id too long for that, only the digest is kept, and an id too long for the digest is refused; - else the profile id, so `--tool copilot` is `copilot`. A name SLIM can't hold is refused at start, whichever of these it came from. The `coordinate` command reaches an agent with `--agents slim:`, and a `SLIM_MEMBER_DIDS` allowlist names the DID derived from that same name. For one release a listener also answers on `agntcy/shadi/-a2a`, which callers from before this change use. Until it goes, two people's `copilot` still share that name, and `slim:@` reaches a remote listener only through it. A task an agent sends (`delegate`, `handoff`, a `NEXT` hop) goes out under `agntcy/shadi/-a2a-client-`, a name of its own for each send, and is signed with the agent's DID. So an agent can call out while its listener runs, several calls at once, and the peer still sees the agent's own DID. ### Request handler stack ```text SlimRpcHandler (agentbridge_a2a) ← SLIMRPC frames GrpcHandler (a2a-grpc) ← official A2A gRPC (tonic) jsonrpc_router / rest_router ← official JSON-RPC / HTTP+JSON (axum) └─ AgentBridgeRequestHandler ← full A2A protocol surface ├─ DefaultRequestHandler ← routes send/get/list/cancel/subscribe/push │ └─ AgentBridgeExecutor ← executes the task against the CliAdapter └─ InMemoryTaskStore ← stores task state for get/list operations ``` `AgentBridgeRequestHandler` implements all A2A request methods and delegates to `DefaultRequestHandler` for everything except `get_extended_agent_card`, which returns a static `AgentCard` describing the adapter: | Field | Value | |-------|-------| | `capabilities.streaming` | `true` | | `capabilities.push_notifications` | `false` | | `default_input_modes` | `["text/plain"]` | | `default_output_modes` | `["text/plain"]` | ### Task execution flow See the [A2A task flow sequence diagram](#a2a-task-flow-inside-a-registered-adapter) above. The executor streams two events: a `Working` status update followed by a `Completed` task carrying the adapter's response text as a `text/plain` part. Task history (the original prompt message) is included in the completed task. ### Tracing Each task a listener receives runs in a `shadi.a2a.receive` span, and each task sent by `delegate`, `handoff`, `coordinate` or a `NEXT` handoff runs in a `shadi.a2a.send` span; a `NEXT` send shows up inside the receive span that caused it. Both carry `a2a.task_id`, `peer.did` and `a2a.outcome`. A receive ends `completed`, `rejected`, `auth_required` or `withheld`; a send records the peer's reply state, or `error` when it never got one. The peer can choose the task, context and message ids, so a receive span also records a local `evaluation_id`, which every refusal quotes back to the sender. Admission and egress policy decisions are events on the span, the egress ones with their own `evaluation_id`. A send carries its W3C `traceparent` in the message metadata, so the receive span joins the sender's trace. Nothing signs that value: it only links traces. Prompts and replies are recorded only when `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`, as the GenAI conventions' `gen_ai.input.messages` and `gen_ai.output.messages`, and only once they have passed admission and the egress policy. [Telemetry](telemetry.md) covers exporting them. ### TLS certificate resolution Without a bearer token (below), the listener needs a client-side mTLS certificate to authenticate with the SLIM node. Resolution order: 1. **Explicit env vars** — `SLIM_TLS_CERT` + `SLIM_TLS_KEY` + `SLIM_TLS_CA` 2. **Agent-specific fallback** — `.tmp/shadi-slim-mtls/client-.crt` / `.key` 3. **Generic fallback** — `.tmp/shadi-slim-mtls/client.crt` / `.key` `SLIM_TLS_CA` defaults to `.tmp/shadi-slim-mtls/ca.crt`. Generate the certificate bundle once with `tools/generate_slim_mtls_certs.sh`. A remote node that authenticates the connection with a bearer token instead takes `SLIM_AUTH_TOKEN_FILE`: a file holding only the token, such as the one `slimctl login` writes. The token goes on every connection and is re-read when the file changes. With a token the fallbacks above aren't used: no client certificate is sent unless `SLIM_TLS_CERT` and `SLIM_TLS_KEY` are set, and the node's certificate is checked against the system roots unless `SLIM_TLS_CA` is set. ### Lifecycle ```text register --slim-endpoint 127.0.0.1:47357 │ ├─ service.connect() connect to SLIM node (TLS 1.3) ├─ shadi_identity::require_did_auth_from_env() │ + shadi_identity::create_app() authenticate with this agent's DID ├─ app.subscribe() subscribe to agntcy/shadi/-a2a (and -a2a) ├─ srv.serve() start the A2A/SLIMRPC event loop │ │ [agentbridge] ready — listening on agntcy/shadi/-a2a │ ├─ … handles tasks until Ctrl-C … │ └─ app.unsubscribe() deregister from the SLIM topic service.disconnect() close the SLIM connection service.shutdown() clean up ``` ### Wiring to `coordinate` The `coordinate` command uses `slim:` specs to reach registered adapters. It constructs a `LiveA2ATaskAdapter` per spec, which speaks the same SLIMRPC protocol to the listening server: ```text coordinate --agents slim:copilot,slim:codex │ ├─ LiveA2ATaskAdapter { peer: agntcy/shadi/copilot-a2a } └─ LiveA2ATaskAdapter { peer: agntcy/shadi/codex-a2a } │ └─ SlimToolAdapter::call() → dispatch() → receives Task(Completed) ``` The A2A traffic is printed with `┌─ A2A ─→` / `┌─ A2A ←─` banners showing the agent ID, coordination phase, epoch, and elapsed milliseconds. ## Security model agentbridge executes real coding tools on your machine and reaches them over a shared SLIM bus, so two trust boundaries matter. ### The register listener is a remote-execution surface A registered adapter forwards every incoming A2A task straight to the local CLI tool (`execute_prompt` → subprocess). Some adapters run their tool with elevated permissions — for example, the Copilot profile invokes `copilot --allow-all-tools` so it can act non-interactively. !!! warning "Any peer able to reach the listener can drive local code execution" Any peer able to reach the listener's SLIM name on the node can drive local code execution through the wrapped CLI tool. Controls: - **Enforced**: `register --slim-endpoint` refuses to start unless the process is running under a sandbox with network blocked by default (`shadi_sandbox::sandbox_enforced`, which checks that the kernel refuses outbound connections rather than trusting environment variables). Seatbelt (macOS), Landlock (Linux), and AppContainer + Job Objects (Windows) sandboxes are all kernel-enforced and inherited by child processes, so wrapping `agentbridge register` in a sandbox such as `shadictl` — `shadictl --net-block --net-allow --read -- agentbridge register ...` — is enough to confine whatever CLI tool the adapter spawns to run a task: it can reach only the listed ports. Give the CLI its own API endpoint as `--net-allow api.example.com:443`, which without `--watch-policy` opens port 443 to any host, or add `--watch-policy` to enforce host names (its network allow-list flags). agentbridge has no sandboxing code of its own; it leans entirely on the same enforcement `shadictl` already provides. The `--read` grant needs the SLIM mTLS client certificate directory so the listener itself can still connect. On macOS, `--allow /tmp` and `--read /tmp` emit both `/tmp` and `/private/tmp` (Seatbelt matches the kernel-resolved path). Resolving a cert directory with `pwd -P` remains valid. - The listener prints a warning on start-up naming the tool that will execute incoming tasks. - Only expose the listener to trusted SLIM peers (`SLIM_MEMBER_DIDS` decides *who* may send a task; the sandbox decides *what* it can do once it runs). - Keep the SLIM node on loopback (`127.0.0.1`) for local demos; only bind a routable address when the peer set is trusted and authenticated. ### DID authentication SLIM apps authenticate with a per-agent DID, not a shared secret. Set `SHADI_SLIM_AUTH=did` and `SLIM_HUMAN_SEED` (the human root key every agent's DID is derived from) or `SHADI_AGENT_KEY` (one agent's base64 signing key, usually injected from the secret store with `shadictl --inject-keychain agent_keys//private=SHADI_AGENT_KEY`, so the seed never reaches the agent; set only one of the two), plus `SLIM_MEMBER_DIDS` — the allow-list of DIDs permitted to participate. `shadi_identity::require_did_auth_from_env` enforces this: it errors out if `SHADI_SLIM_AUTH` isn't `did`, so `register`, `delegate`, and `coordinate` cannot silently fall back to a shared secret. Nothing ties an injected `SHADI_AGENT_KEY` to the agent name it is used with: inject the wrong agent's key and the listener signs as that agent. So a `register` listener prints the DID it signs as and where the key came from, and refuses to start when another live local listener (`list --local`) already holds that DID under a different name. See the [Secure Agent Group Demo](demos/did-agent-group.md) for a full worked example, including how DID admission is verified against the allow-list. ### Transport authentication SLIMRPC peer-to-peer A2A authenticates to the SLIM node with mutual TLS, or with a bearer token from `SLIM_AUTH_TOKEN_FILE`. The listener resolves a client certificate from `SLIM_TLS_CERT` / `SLIM_TLS_KEY` / `SLIM_TLS_CA`, an agent-specific fallback, or a generic fallback (see [TLS certificate resolution](#tls-certificate-resolution)). Generate the bundle with `tools/generate_slim_mtls_certs.sh` and keep the CA private to the peers you trust. gRPC listeners use a separate `A2A_TLS_*` pair and must not reuse those SLIM files. ## Multi-agent coordination layer (`agentbridge_mas`) `agentbridge coordinate` is a driver for [AgentBridge MAS](mas.md). That crate owns epochs, engines, and ASSEMBLY / CONVERGE. This page only covers how AgentBridge feeds it. `coordinate` builds a roster, optionally runs ASSEMBLY, then constructs `MasRuntime` for the class and turns tool replies into `SemanticEvent`s. `--pattern development` (default) uses `DevelopmentEngine`. `--pattern preference|cascade|resource` uses the scalar paper driver. `--assembly` infers the class first. See [ASSEMBLY and CONVERGE](assembly-converge.md). `LiveA2ATaskAdapter` (in `agentbridge_mas::experiments`) is the live task dispatch used by `delegate`, `handoff --from/--to slim:…`, and `coordinate` over SLIM or official A2A unicast. `CliToolAdapter` is AgentBridge’s `ToolAdapter` over a local CLI profile. ### DevelopmentEngine `DevelopmentEngine` is the CONVERGE engine for a shared code artifact. `agentbridge coordinate --pattern development` (default) stays here. ASSEMBLY, other classes, skills, and halt rules are in [ASSEMBLY and CONVERGE](assembly-converge.md). | Event | Payload | Effect | |-------|---------|--------| | Code proposal | `ExternalBytes(code)` | Stored keyed by source agent | | Endorsement vote | `ToolResult { accepted: true, tool_name: agent_id }` | Votes tallied per artifact | | Other payloads | any | Accepted silently (applied) | | Finalization | — | Artifact with most votes wins; epoch advances | | Max rounds exceeded | — | Force-finalizes with current best artifact | Epoch discipline prevents duplicate, stale, and future-epoch events from corrupting the state machine. ??? note "Goal analysis: what was asked for vs. what is built" ### Original goal > "Write a new application to interconnect Claude CLI, Copilot CLI, Codex CLI or > other similar applications to exchange context or messages, artifacts etc. > Use the A2A protocol, SLIM/shadi for transport, and DIR to discover each other. > Make agents coordinate with a goal and work in autonomy until the work is achieved." ### What is implemented | Requirement | Status | Detail | |-------------|--------|--------| | Architecture design | ✅ | Full A2A + SLIM + DIR stack documented | | Coordination backbone | ✅ | `agentbridge_mas` migrated + `DevelopmentEngine` added | | `CliAdapter` trait | ✅ | Unified interface for any coding tool | | `ContextPacket` | ✅ | Portable session snapshot with JSON serde | | Generic subprocess adapter | ✅ | `GenericStdioAdapter` — newline-delimited JSON protocol | | Register profiles | ✅ | `ProfileAdapter` + `crates/agentbridge/profiles/*.json` (no per-CLI Rust) | | `CliToolAdapter` bridge | ✅ | Any `CliAdapter` → `agentbridge_mas::ToolAdapter` | | DIR registration | ✅ | Real AgentCard (skills + SLIM endpoint) published to DIR's `integration/a2a` OASF module, DID carried in `authors` | | DIR-driven group discovery | ✅ | `MemberSource` (skill search / DID lookup / explicit list) resolves SLIM group trust sets from Directory — see the [Agent Directory Discovery Demo](demos/dir-group-discovery.md) | | `agentbridge` library | ✅ | `crates/agentbridge` | | CLI binary | ✅ | `agentbridge register \| list \| handoff \| delegate \| coordinate` | | Live A2A transport | ✅ | `LiveA2ATaskAdapter` wired into `register`, `delegate`, `handoff --from/--to slim:…`, and `coordinate` | | Quorum-vote finalization | ✅ | `DevelopmentEngine` — autonomous, no human required | | SLIM group relay | ✅ | `agentbridge slim a2a-collaborate` (SLIMRPC `Collaborate` RPC via `agentbridge_a2a::A2AGroupChannel`) — see [SLIM and A2A](slim_a2a.md) | | DID-identified secure groups | ✅ | Moderator-invited channels admitted against a per-agent DID allow-list — see the [Secure Agent Group Demo](demos/did-agent-group.md) | | Application-layer DID proof | ✅ | Send/recv bound to `did:key`; forged DID rejected; `AUTH_REQUIRED` re-prove/ask/deny | | Native `handoff` specs | ✅ | Same `--from`/`--to` as `coordinate`, including `cursor-agent` and `slim:` | | `register --tool cursor-agent` | ✅ | Same sandbox + DID listener as the other tools | | `list --local` | ✅ | Live listeners from on-host register leases | | Two-line token-passing coding | ✅ | [Round-robin Rust Demo](demos/collab-rust.md) — `avatar` `delegate` + capped apply + agent-as-A2A-client `NEXT` until `cargo test` ([sample run](demos/collab-rust-sample.md)). Same fifo outcome over official A2A unicast without a SLIM node: [A2A unicast](demos/a2a-grpc.md) ([sample run](demos/a2a-grpc-sample.md)). | ### What remains | Requirement | Detail | |-------------|--------| | `ContextPacket` persistence | An encrypted store; `shadi_memory` provided one before the split and now lives in [shadi](https://github.com/agntcy/shadi) | ### Does the existing middleware help? **Yes — substantially.** Every component of the target architecture existed or was extended from existing infrastructure: - **A2A**: `agentbridge_a2a::A2AChannel` / `A2AChannelBuilder` provide identity-verified A2A over SLIMRPC or gRPC. `LiveA2ATaskAdapter` in `agentbridge_mas` is a ready-made task dispatcher. - **SLIM**: `agentbridge_transport_slim::NativeSlimSession` and `LiveSlimMessagingAdapter` provide group and point-to-point messaging. The `LiveSlimGroupSender` handles multi-agent broadcast with receipt acknowledgements. - **DIR**: a `dir` subcommand already integrated with `agntcy/dir`. OASF records are the natural format for adapter agent cards. - **agentbridge_mas**: The `DevelopmentEngine` required a new `PatternKind` and engine implementation, but the runtime, epoch discipline, adapter traits, and test infrastructure were already in place. - **Memory**: an encrypted `ContextPacket` store was available with no additional code. That crate stayed in shadi when the repositories split. The middleware was designed for exactly this use case. The agentbridge application is an adapter layer on top of an existing, tested coordination stack. ??? note "File map" ``` crates/ agentbridge/ ← library src/ adapter.rs ← CliAdapter trait + CliToolAdapter context.rs ← ContextPacket, CodeContext, ArtifactPayload dir_registry.rs ← AgentCard → OASF module wrapping + dirctl integration local_registry.rs ← on-host leases for `agentbridge list --local` member_source.rs ← MemberSource (skill/DID/explicit list) group-discovery trait adapters/ generic_stdio.rs ← subprocess JSON protocol adapter profile.rs ← ProfileAdapter (JSON under profiles/) agentbridge_cli/ ← binary (agentbridge) src/ main.rs commands/ register.rs ← register + SLIM A2A listener list.rs handoff.rs delegate.rs ← single-shot A2A dispatch coordinate.rs ← MasRuntime driver (ASSEMBLY / CONVERGE) agentbridge_mas/ ← coordination runtime (AgentBridge MAS) ``` ## Next steps - Read [AgentBridge MAS](mas.md) for the coordination runtime, then [ASSEMBLY and CONVERGE](assembly-converge.md) for the group protocol. - Try the [Secure Agent Group Demo](demos/did-agent-group.md) for a full multi-agent, DID-identified walkthrough. - Try the [Round-robin Rust Demo](demos/collab-rust.md) for a multi-turn loop where each agent may write at most two lines and chooses the next A2A peer. - Try the [Agent Directory Discovery Demo](demos/dir-group-discovery.md) to form and grow a group by discovering members in DIR instead of naming them by hand. - Try the [Runtime Discovery Demo](demos/dir-runtime-discovery.md) to run an agent skill from DIR as an agent (`register --record`), announce it to runtime discovery (`--dir-announce`) and find it by skill while it runs. - Review the transport layer in [SLIM and A2A](slim_a2a.md). - See [shadi](https://github.com/agntcy/shadi) for sandboxing guidance, or use any sandbox that blocks network by default.