# Demo: a DID-identified group of coding-agent CLIs This walkthrough forms a SLIM group where a **moderator** (bound to a human identity) creates a channel and invites four coding-agent CLIs — **claude-code**, **codex**, **copilot**, **cursor-agent** — as members. Every participant authenticates with its own `did:key`, and every DID is **derived from the same human key**, so the mesh can tell which human an agent belongs to. It uses only `agentbridge slim` commands. You can run it two ways: - **One command (recommended):** `bash docs/content/demos/run-demo.sh` orchestrates the whole flow — node, moderator, four agents, invites, an A2A roll-call broadcast, and real task delegation to claude-code/codex/copilot — and prints the result. Best for a quick, reliable demo. It prints its log dir immediately and echoes a one-line status per phase as it runs; in a second terminal, `bash docs/content/demos/watch-demo.sh` tails every per-agent log live (including ones from later phases, as they're created) so you can watch progress in real time instead of waiting for the final summary. - **By hand:** run one `agentbridge slim` command per agent terminal (steps 1–6 below). Best for exploring; note that `slim join` and `slim group` both stay in the foreground, so mind the choreography and use generous `--timeout-seconds` values. ## What this shows - **Per-agent DID identity** — each CLI proves itself with a `did:key`/EdDSA JWT instead of a shared secret. - **Human ↔ agent binding** — all five agents are HKDF-derived from one human root key (salt `shadi-agent-derive`), so they share one **human DID**. - **Moderator role** — the channel creator/inviter is the human's `avatar`; members join and are admitted against a DID allow-list. - **Role-visible UX** — `create`, `invite`, and `whoami` surface the DID, the human it belongs to, and the moderator/participant role. - **A2A-native group messaging** — `slim a2a-collaborate` broadcasts and receives through A2A's `Message` type (SLIM's group/multicast is used underneath A2A via the SLIMRPC `Collaborate` RPC, not instead of it), with `slim-src` attribution. - **Real coding-agent CLIs in the loop** — `agentbridge` wraps the actual `claude`/ `codex`/`copilot`/`cursor-agent` binaries as SLIM/A2A listeners under the same DID identity, so a delegated task really executes on that CLI, not a mock. Outbound A2A text is DID-signed; `list --local` shows the listeners on this host. ## Prerequisites ```bash # 1. Install the released CLI (docs/content/install.md); `agentbridge` must be on PATH brew tap agntcy/agentbridge https://github.com/agntcy/agentbridge brew install agntcy/agentbridge/agentbridge # 2. Optional, for step 7 (real coding-agent CLIs): the released sandbox CLI brew tap agntcy/shadi https://github.com/agntcy/shadi brew install agntcy/shadi/shadictl # 3. Generate mTLS material for the SLIM transport (one CA + client/server certs) export DEMO=/tmp/shadi-did-demo bash tools/generate_slim_mtls_certs.sh "$DEMO/shadi-slim-mtls" ``` ## 1. Shared environment (every terminal) The whole group shares one human root secret and one allow-list, provided in [`demo-env.sh`](demo-env.sh). From the repo root, `source` it in **every** terminal below: ```bash source docs/content/demos/demo-env.sh ``` It sets `SHADI_SLIM_AUTH=did`, `SLIM_HUMAN_SEED`, `SLIM_HUMAN_DID`, `AGENTBRIDGE_TMP_DIR`, `SLIM_ENDPOINT`, the shared transport cert (`SLIM_TLS_CERT`/`SLIM_TLS_KEY`), and the `SLIM_MEMBER_DIDS` allow-list — the DID of every member (moderator + 4 agents). Each agent's DID is derived from `SLIM_HUMAN_SEED` + its `SHADI_AGENT_ID`: | `SHADI_AGENT_ID` | role | `did:key` | |---|---|---| | `avatar` | moderator | `z6Mkix7tAk25UD8f4Uy7tTxn1FAErhGZ7rfifBgrvdKgzM82` | | `claude-code` | participant | `z6MkhRuJgsaipjWB6No8RUGD4P7fnn8qGBZKK5C5zGJjPZa1` | | `codex` | participant | `z6MkmaFFysqqMsE1q5M6E7LDuoJMaSBv3PkNHz5SwwwnuGr6` | | `copilot` | participant | `z6MkmJUcT1F6BK21nQv1C2zo46gJJA9hsMGnbdpiN2LrMnwT` | | `cursor-agent` | participant | `z6MktdzQzm171sAoRZc6cCUPDa8XWxaG8Bi6R3Y4ohP7qS5Q` | | `goose` | participant | `z6MkjiDFxXFe2sM4vXZH8fT3XYLmjNDeVobo4VgNayc7aEKD` | ## 2. Discover a member's DID (optional) You don't have to precompute the table — any agent prints its own DID with `whoami`. In a fresh terminal, `source demo-env.sh`, then: ```bash SHADI_AGENT_ID=claude-code agentbridge slim whoami ``` ```text agent agntcy/shadi/claude-code auth: did role: none did: did:key:z6MkhRuJgsaipjWB6No8RUGD4P7fnn8qGBZKK5C5zGJjPZa1 human: did:key:z6MkhVTmZLk7g6zRXm8DF2u2Y5b2WCkC75n16xuoJDN1X4Bp ``` Collect each agent's `did:` line to build `SLIM_MEMBER_DIDS`. ## 3. Moderator: start the SLIM node **Terminal M** (`source demo-env.sh` first). The node stays in the foreground for the whole demo: ```bash SHADI_AGENT_ID=avatar agentbridge slim start-node ``` ```text started SLIM node on 127.0.0.1:47560 ``` ## 4. Each agent waits to be invited Open a terminal per agent (`source demo-env.sh` first). `slim join` subscribes to the channel and then **blocks**, waiting for the moderator's invitation — so start these *before* step 5. Subscribing does not require the channel to exist yet. **Terminal claude-code:** ```bash SHADI_AGENT_ID=claude-code agentbridge slim join \ --channel agntcy/shadi/dev-room --timeout-seconds 120 ``` ```text agent agntcy/shadi/claude-code auth: did role: none did: did:key:z6MkhRuJgsaipjWB6No8RUGD4P7fnn8qGBZKK5C5zGJjPZa1 human: did:key:z6MkhVTmZLk7g6zRXm8DF2u2Y5b2WCkC75n16xuoJDN1X4Bp waiting up to 120s for an invitation to agntcy/shadi/dev-room ``` Repeat in three more terminals with `SHADI_AGENT_ID=codex`, `copilot`, and `cursor-agent` (same `slim join` command). Each stays attached until interrupted; without `--timeout-seconds` it waits indefinitely. ## 5. Moderator: open the channel and invite the four Back in **Terminal M** — in a second moderator terminal, since step 3's node holds the first. `slim group` creates the channel, invites every member, and then stays attached as moderator until you interrupt it: ```bash SHADI_AGENT_ID=avatar agentbridge slim group \ --channel agntcy/shadi/dev-room \ --invite agntcy/shadi/claude-code \ --invite agntcy/shadi/codex \ --invite agntcy/shadi/copilot \ --invite agntcy/shadi/cursor-agent ``` ```text created channel agntcy/shadi/dev-room as moderator agntcy/shadi/avatar (did:key:z6Mkix7tAk25UD8f4Uy7tTxn1FAErhGZ7rfifBgrvdKgzM82) — human did:key:z6MkhVT… agent agntcy/shadi/avatar auth: did role: moderator did: did:key:z6Mkix7tAk25UD8f4Uy7tTxn1FAErhGZ7rfifBgrvdKgzM82 human: did:key:z6MkhVTmZLk7g6zRXm8DF2u2Y5b2WCkC75n16xuoJDN1X4Bp invited agntcy/shadi/claude-code to agntcy/shadi/dev-room (moderator did:key:z6Mkix7t…) invited agntcy/shadi/codex to agntcy/shadi/dev-room (moderator did:key:z6Mkix7t…) invited agntcy/shadi/copilot to agntcy/shadi/dev-room (moderator did:key:z6Mkix7t…) invited agntcy/shadi/cursor-agent to agntcy/shadi/dev-room (moderator did:key:z6Mkix7t…) channel agntcy/shadi/dev-room is open with 4 invited member(s); interrupt to close it ``` Each agent terminal reports `joined agntcy/shadi/dev-room; interrupt to leave` — the group is now formed: one human's moderator plus its four coding-agent CLIs, every member cryptographically identified by a `did:key` admitted against the shared allow-list. `--invite` takes a SLIM name literally, which is what a peer that joined with `slim join` registers under. To build the group from the Directory instead, pass `--members skill:…`, `--members did:…` or `--members running:…`: those resolve to candidates addressed at the listener their DID implies, and form the group's trust set — that is the [Agent Directory Discovery Demo](dir-group-discovery.md). ## 6. Roll call — every agent introduces itself Messaging always goes through **A2A**, not raw SLIM bytes: `slim a2a-collaborate` drives the SLIMRPC `Collaborate` RPC — an A2A operation that broadcasts each `Message` you send to every other member of a SLIM group channel, and streams back everyone else's messages with `metadata["slim-src"]` identifying the sender. Every member (moderator included) both sends its own intro and listens for everyone else's, in one call — no `slim group`/`slim join` needed for this step, since `Collaborate` forms its own group session (it's independent of the moderator/role session from steps 3–5 above). **Each terminal — moderator and all four agents — runs the same shape (e.g. claude-code):** ```bash SHADI_AGENT_ID=claude-code agentbridge slim a2a-collaborate \ --peer-agent-ids codex,copilot,cursor-agent,avatar \ --message "Hi, I am claude-code — reporting in" --timeout-seconds 15 ``` ```text broadcast "Hi, I am claude-code — reporting in" to 4 peer(s); received: Hi, I am codex — reporting in Hi, I am copilot — reporting in Hi, I am cursor-agent — reporting in Hi, I am avatar — reporting in ``` Give every terminal the peer-list of the *other* four members and start them all within the timeout window — this is a genuine mesh: every member reaches every other member directly, not just moderator → members. ## 7. Delegate a real task to the coding-agent CLIs Everything so far shows *identity* and *messaging*. This step wires in the real thing: **`agentbridge`** wraps the actual installed `claude`, `codex`, `copilot`, and `cursor-agent` CLIs as SLIM/A2A listeners, so a delegated task really invokes that CLI and returns its real output — using the *same* DID identity from step 1 (agentbridge reads the same `SHADI_SLIM_AUTH=did` environment from step 1). Outbound A2A text is DID-signed; unsigned inbound parks as `AUTH_REQUIRED`. **Each agent terminal (e.g. claude-code)** — registers a live adapter backed by the real CLI, reachable at `agntcy/shadi/claude-code-a2a`. `agentbridge register --slim-endpoint` refuses to start unless it is already running under a sandbox that blocks network by default: a remote-reachable listener must not execute tasks unsandboxed. agentbridge implements no sandbox of its own — it probes for one, so **any** confinement satisfies it, and the kernel policy is inherited by whatever CLI the adapter spawns to run a task. Under a container, with nothing from SHADI: ```bash docker run --network=none ... agentbridge register --tool claude-code \ --command "$(pwd)" --a2a-listen "$SLIM_ENDPOINT" ``` Or under [SHADI](https://github.com/agntcy/shadi)'s `shadictl`, whose Seatbelt / Landlock / AppContainer policies give the same guarantee — install the released `shadictl` (see Prerequisites); it is not part of agentbridge: ```bash SHADI_AGENT_ID=claude-code shadictl --net-block --net-allow "$SLIM_ENDPOINT" \ --read "$AGENTBRIDGE_TMP_DIR" --allow "$AGENTBRIDGE_TMP_DIR/agentbridge-local" -- \ agentbridge register --tool claude-code \ --command "$(pwd)" --slim-endpoint "$SLIM_ENDPOINT" ``` ```text Registered Claude Code adapter (agent id: claude-code, dir: /path/to/shadi) Starting SLIM A2A listener on 127.0.0.1:47560 as agntcy/shadi/claude-code-a2a ... [agentbridge] ready — listening on agntcy/shadi/claude-code-a2a ``` Repeat for `codex`, `copilot`, and `cursor-agent` (same shape, `--tool `). `--allow "$AGENTBRIDGE_TMP_DIR/agentbridge-local"` lets the listener write its lease there, which `agentbridge list --local` reads; the rest of `$AGENTBRIDGE_TMP_DIR` (the mTLS material) stays read-only. That policy only lets the listener itself run, and the wrapped CLI inherits it. To have the CLI do real work, also grant what it needs: its API host (`--net-allow api.anthropic.com:443` for claude-code, `chatgpt.com:443` for codex) and write access to its config directory (`~/.claude`, `~/.codex`, `~/.copilot`, `~/.cursor`). [`run-demo.sh`](run-demo.sh) grants these; set `DEMO_NET_ALLOW="host:443,..."` or `DEMO_WRITE="/path,..."` to add more, for example a different Copilot API host for an organization account. Then, from any terminal, list the listeners this machine just started: ```bash agentbridge list --local ``` ```text Local agentbridge adapters: claude-code did=did:key:z6MkhRuJ… slim://127.0.0.1:47560 codex did=did:key:z6MkmaFF… slim://127.0.0.1:47560 copilot did=did:key:z6MkmJUc… slim://127.0.0.1:47560 cursor-agent did=did:key:z6MktdzQ… slim://127.0.0.1:47560 ``` **Moderator terminal** — delegates one real task to each (same shape for `cursor-agent`): ```bash agentbridge delegate "Reply with exactly the single word: PONG" \ --to claude-code --agent-id avatar --endpoint "$SLIM_ENDPOINT" ``` ```text Delegating task 09024c44-... to 'claude-code'... Response from 'claude-code' (5518ms): PONG ``` The listener terminal prints the same round trip from its side: ```text ┌─ A2A recv [claude-code] task ... │ Reply with exactly the single word: PONG └───────────────────────────────────────────────────────── ┌─ A2A send [claude-code] (5518 ms) │ PONG └───────────────────────────────────────────────────────── ``` **Chaining a real task across agents** — `run-demo.sh` does this for real: it delegates a disk-usage check to `codex`, a top-CPU-processes check to `copilot`, then hands *both real outputs* to `claude-code` and asks it to synthesize an operational report — each step genuinely depends on the previous agent's result, not a canned reply. By hand, that's three `delegate` calls chained through shell variables: ```bash DISK=$(agentbridge delegate \ "Run a disk usage check on this machine (e.g. df -h) and report the real output." \ --to codex --agent-id avatar --endpoint "$SLIM_ENDPOINT") CPU=$(agentbridge delegate \ "Rank the top 10 processes on this machine by CPU usage (e.g. ps aux) and report the real output." \ --to copilot --agent-id avatar --endpoint "$SLIM_ENDPOINT") agentbridge delegate \ "Summarize these two real system-health snippets into a short report, flagging anything concerning:\n\n$DISK\n\n$CPU" \ --to claude-code --agent-id avatar --endpoint "$SLIM_ENDPOINT" ``` `claude-code`'s response is a real report — e.g. flagging a disk volume nearing capacity or a process with unexpectedly high CPU — built from the other two agents' real command output. This is a genuinely live `claude`/`copilot`/`cursor-agent` process handling the prompt — swap the message for any real coding task to see it delegated end to end. Native handoff uses the same specs as `coordinate`: ```bash agentbridge handoff --from copilot --to claude-code ``` `codex`'s success depends on your local `codex` CLI/model configuration (an unsupported default model returns a `400` from the OpenAI backend, unrelated to agentbridge); that's an environment issue, not a bug in this wiring. ## How admission works (under the hood) - The moderator's `create`/`invite` control messages carry its DID-JWT; each participant verifies that JWT against `SLIM_MEMBER_DIDS` (the allow-list) before replying — a non-member DID is dropped, so only invited agents can be admitted. - Because every DID is HKDF-derived from `SLIM_HUMAN_SEED`, the `human:` line is the same for all five, which is how the mesh attributes each agent to its human. - Switching the whole group back to the legacy shared secret is just `unset SHADI_SLIM_AUTH` (the commands then use `SLIM_SHARED_SECRET`); `slim group` and `slim join` work the same way, without the DID lines. ## Notes and limitations - `slim join` **blocks** (listening for the moderator's invite) — an agent terminal will appear to "hang" until invited, or the timeout elapses. That is expected, and it stays attached afterwards; interrupt it to leave. `slim group` stays in the foreground as moderator the same way. - `slim a2a-collaborate` also blocks for its `--timeout-seconds`, since it stays listening for other members' broadcasts for that whole window after sending its own intro. - Verified live with the full 5-member group (moderator + 4 coding-agent CLIs): every member reliably receives all four peers' intros, in either order, across repeated runs. - Server-side listener attribution is a known gap in the current SLIMRPC `Collaborate` implementation: a member's *own* broadcast gets proper `slim-src` attribution on its reply-observer stream, but messages surfaced purely through the passive listener path have no per-message sender tag yet (the message text itself states the sender, which is enough for this demo). - `agentbridge register --tool claude-code|codex|copilot|cursor-agent` needs that CLI actually installed (and authenticated) on PATH. A `delegate` failure usually means the target CLI itself errored (auth, unsupported model, a network host the sandbox blocks, etc.), not the SLIM/A2A wiring — the response text includes the real error from that CLI so it's easy to tell apart. - Step 7 needs an `agentbridge` that includes the closed-admission fix ([#87](https://github.com/agntcy/agentbridge/issues/87)); on 0.5.1 and earlier the `register --slim-endpoint` listeners refuse to start without a message gate. ## Next steps - Continue with a multi-turn coding loop (two lines of Rust per agent, round-robin until tests pass) in the [Round-robin Rust Demo](collab-rust.md). - Read the concept-level model behind this demo in [SLIM and A2A](../slim_a2a.md). - See [AgentBridge](../agentbridge.md) for the full CLI coding-agent interconnect this demo exercises. - Look up exact `agentbridge` flags in the [CLI Reference](../cli.md).