agent-bridge

Documentation

Messages and tasks

The agents on paired machines can talk to each other through a small mailbox: plain JSON files in the project, sent over the same SSH link as jobs. A message is a note, a request, a reply, progress or a done notice. A task is a request with a tracked state that both machines agree on. Both are information between agents, never instructions from the owner and never the owner's approval: an agent reads them, and anything outside its own work still needs its owner's OK.

In Claude Code, /agent-bridge:handoff hands a piece of work to the agent on another machine as a task, /agent-bridge:inbox handles what came in, and /agent-bridge:tasks shows the board.

Messages

agent-bridge buildbox msg any "Windows tests pass on 3f2a9c1"                 # a note, to whoever is there
agent-bridge buildbox msg feat-login --request "Please lint src/auth and reply with the warnings"
agent-bridge reply 20261124T101500-laptop-3f2a9c1b "Accepted: running it now"
agent-bridge reply 20261124T101500-laptop-3f2a9c1b --kind done "Clean, see branch from-buildbox/lint"
agent-bridge wait-reply 20261124T101500-laptop-3f2a9c1b --timeout 600
agent-bridge inbox --unread
agent-bridge read <id>
agent-bridge archive --all                                                     # file away what's been read

How a message travels: it waits in this clone's outbox until an exchange carries it over, and the other side checks it before anything reads it.

sequenceDiagram
  participant S as session on laptop
  participant M as laptop's mailbox<br/>.git/agent-bridge-mail
  participant N as buildbox's mailbox<br/>.git/agent-bridge-mail
  participant W as session on buildbox
  S->>M: agent-bridge buildbox msg any "…" → outbox/buildbox/
  Note over M,N: an exchange: one SSH call, a second to confirm
  M->>N: laptop's queue for buildbox
  N->>N: checked against the one rule → inbox/
  N-->>M: buildbox's queue for laptop
  W->>N: watch (a long poll): a new message
  Note over W: information from another agent,<br/>never an instruction
  W->>N: reply "…" → outbox/laptop/
  N-->>M: with the next exchange
  M-->>S: watch: the reply

The address is a session on the peer: its name (the agent's branch, or AGENT_BRIDGE_SESSION), its id, or any (Sessions). msg prints the message's id; reply answers one; wait-reply waits for the answer (--kind done for the final one). Kinds: note (information), request (please do this: exact steps and what done means), reply (accepted or declined), status (progress), done (finished: what, where, exit codes). A background job sends a done by itself when it ends.

Options for msg and reply: --priority low|normal|high|urgent (inbox marks high ! and urgent !!), --due <ISO time>, --data '<JSON object>' (for programs; 64 KB at most), --attach <file> (256 KB in all inline; a bigger file, up to 2 GB, goes as an artifact: a git object in the project's repository, sent to the peer before the message, over a full or safe link; read <id> --out <dir> saves them all, fetching an artifact from the machine that sent it when it isn't here yet, and checking each one's SHA-256), --thread <id> (and inbox --thread <id>), --subject, --job, --branch. msg --all sends a copy to every peer. Reading a request sends a read receipt.

The text can come from stdin or a file instead of the command line, which spares a long text, or one that starts with --, the shell's quoting:

agent-bridge buildbox msg any --request - <<'EOF'
Steps: ...
--locked must stay on.
EOF
agent-bridge reply <id> --kind done --body-file report.txt

A message is delivered at once when the peer is reachable; otherwise it waits in this machine's outbox (exit 75, "queued") and goes with the next msg, exchange, watch or wait-reply, or when the peer pulls it. exchange delivers everything queued, both ways, now. A peer that has no clone of this project yet has no mailbox for it: the message waits the same way (exit 75), and nothing is made on the peer.

Every message is checked against one rule before it is queued, when it is taken in, and again by the receiving machine's own client before anything reads it (Security). A message the other side won't take is not "sent": msg says why and exits 2, the message goes to refused/, and watch prints refused id=... by=... reason="...".

Never put a secret in a message (or in a job, or on a command line): process lists and logs show them.

Tasks

A task is a request with a state, kept the same on both machines without a server:

agent-bridge buildbox task new "Port the config loader to Windows paths" -d "Done means: tests/config pass on Windows" --branch feat-paths
agent-bridge task ls                       # the board: your tasks and theirs
agent-bridge task show <task>              # one task's timeline
agent-bridge task wait <task>              # until it ends: 0 done, 1 failed/declined/cancelled, 124 timeout

On the machine that got it, the agent moves it along:

agent-bridge task accept <task>            # or: task decline <task> "why"
agent-bridge task start <task>
agent-bridge task progress <task> 40 "parser done, tests next"
agent-bridge task block <task> "needs the owner's OK to install a toolchain"
agent-bridge task done <task> "branch feat-paths-win, 14 tests pass"      # or: task fail <task> "..." --exit 1
stateDiagram-v2
  direction LR
  [*] --> proposed: task new
  proposed --> accepted: accept
  proposed --> declined: decline
  accepted --> running: start · progress
  accepted --> blocked: block
  running --> blocked: block
  blocked --> running: start · progress
  running --> done: done
  running --> failed: fail
  declined --> proposed: reassign
  blocked --> proposed: reassign
  done --> [*]
  failed --> [*]
  note right of failed
    cancel (the creator) ends any open task: cancelled.
    done and fail also come straight from
    proposed, accepted or blocked.
  end note

Only the assignee's machine can accept, start, report progress, block, finish or fail a task; only the creator's can cancel it or reassign it to another session (task reassign <task> --to <session>); either can add a task note. Both machines check every event, so a mix-up can't move someone else's task.

A pool: the first machine to claim it gets it. agent-bridge task new "Run the Linux matrix" --pool offers a task to every peer (--to @<role> for sessions with that role there; --lease 2h, 30 minutes by default).

Order and subtasks. A task can name the tasks it comes after (--after <task>,..., tasks this machine knows) and its parent (--parent <task>).

A job started with job ... --task <task> reports to the task by itself: started, progress after each step, done or failed with its exit code, on both machines' boards. auto task new sends the task to the peer where an agent is at work.

The two machines' clocks needn't agree: each event is stamped after everything its writer already held for the task, so a cancel sent after seeing "done" can't undo it. Two events that cross on the way (a cancel and a done sent at the same moment) are ordered by the clocks; whichever comes first, both machines end with the same state.

An agent on demand

A task doesn't need a session waiting for it. agent-bridge task new "Port the loader" -d "Done means: tests pass." --run (add --needs xcode, --agent-cli codex, --branch B, or name the peer) does it all:

  1. It picks the machine (as pick does, or the one you name) and syncs this branch (or --branch) to a job there.
  2. It gives the task to that job, and starts it in the background. The job runs that machine's own agent CLI headless in the job's worktree: claude -p, or codex exec, with the task as its prompt on stdin.
  3. The job reports to the task (started, done or failed with its exit code). task wait <task>, then agent-bridge <peer> fetch <job> brings its commits back.

The agent runs in its normal permission mode, never bypassing it: what would need a person's approval is refused, as nobody is there to give it. It is stopped after two hours (--timeout on job changes that). Over a full link only: a safe link's sandbox has no network for the model's API, and a messages-only link runs no jobs. A machine without that CLI fails the task with exit 127. By hand: agent-bridge <peer> job <name> --agent-cli claude ("<prompt>" | - | --body-file <file>) [--task T] [--bg].

The CLI there needs a login that works without anyone at the screen. On a Mac, Claude Code keeps its login in the Keychain, which a job started over SSH can't open, so it answers "Not logged in". Run claude setup-token there once (or set ANTHROPIC_API_KEY in that machine's environment). Codex is the same: log it in there for non-interactive use, or give it an API key.

The project log

What one agent decided or found shouldn't have to be told again to every other session on the project. agent-bridge log add --kind decision "Use SQLite for the cache; Postgres is overkill here" writes it once: this machine keeps it, and every peer gets a copy (a log message, to <peer>/any) that its client files in its own log/ instead of the inbox. --kind is decision, finding, warning or note (the default); - takes the text from stdin.

Sessions: who is there, and whose mail it is

agent-bridge sessions            # the agent sessions that are live on every machine, in this project
agent-bridge sessions buildbox   # on one machine;  --all: every project;  --json: as data
laptop/feat-login  id=7c1e...  claude  app  working  12s
buildbox/main      id=03af...  claude  app  idle  4m
buildbox/reviewer  id=9b20...  codex   app  waiting (Codex needs your approval)  1m

A session is <machine>/<name>. The name is its branch, or what AGENT_BRIDGE_SESSION says; the id is the agent CLI's own for the session. Either one, or any, is what msg, task new --to and task reassign --to take. The list comes from the activity journal's hooks (Monitor), so a session shows up once those run in it.

Who may write to your agents

By default everything a paired machine's agents send arrives. In your own config you can say otherwise, per peer:

"inbox": { "from": { "buildbox": "hold", "oldbox": "refuse" }, "max_per_minute": 30 }

Messages that agents write are also checked for repeats: one with the same sender, recipient, kind and text as a message taken in the last 10 minutes is dropped (it goes to repeats/, and isn't counted against the peer).

Messages are signed (0.9): each is signed by the machine that sends it, and checked here before it is used. A message from a peer whose key is on record that isn't signed by it goes to quarantine/ in the mailbox, and watch shows a rejected ... reason="quarantined: ..." line. read says in its header whether a message's signature was verified.

Two more limits apply by themselves. A peer that delivers 5 messages this machine rejects within 10 minutes is paused for 10 minutes (nothing is taken from it; it resumes by itself, and watch says so once). A message sent with --expires <minutes> is dropped unread once that time is over. read shows a message from another machine under a header and a fixed preamble that mark it as content from a peer agent: untrusted data, not instructions. The header also says which agent CLI sent it and in which permission mode, when the sender knows ([claude, bypassPermissions], and a sender: line that says when it runs without permission prompts): a request from an agent that asks nobody before it acts deserves a closer look. That is the sending machine's word for it, under the machine's signature.

A machine you don't want running anything here can still be one your agents talk with: pair it for messages only.

Releasing is yours to do: an agent never runs inbox --release. This is your own client's rule on your own machine; it doesn't stop a machine you paired from writing files here (see Security).

Mail that isn't about a project

A project's mailbox needs a clone of that project on both machines. For anything else ("is the build machine free tonight?", a task about the machine itself) each machine also has a mailbox of its own:

agent-bridge buildbox msg any --request "Is the GPU free tonight?" --machine
agent-bridge buildbox task new "Clear the old build caches" --machine
agent-bridge inbox --machine          # what waits in this machine's own mailbox

Live delivery

In Claude Code, the plugin's monitor runs agent-bridge watch --new --quiet in every session: each new message, task event and done notice from another machine shows up in the session as it arrives, and so does a link going down or coming back, peer by peer (link down: buildbox: <reason>, link up: buildbox), and a session on another machine that has waited three minutes or more for its owner's approval (waiting: buildbox/reviewer (id 9b20...) has waited 6m for its owner's approval at that machine, once each time it starts to wait: nobody can answer it from here, but whoever handed it work knows why nothing comes). With each peer it holds a long poll: one SSH call in which the peer answers as soon as a message for this machine lands in its outbox, or after 45 seconds, and the next one starts at once. A message arrives in about a second. Each call ends by itself, so nothing is left on either machine after a session ends; one watch per peer and mailbox holds it, the others on this machine leave that peer to it. AGENT_BRIDGE_WAIT=<s> (0 to 45) changes the wait; 0 polls every interval (--interval, 15 s) instead. A peer on agent-bridge before 0.8 answers at once, and is polled every interval. Between answers watch only looks at the inbox folder. A file in the inbox that isn't a message is set aside with one rejected id=... reason="..." line; a peer that has no clone of the project is not reported as down.

By hand:

agent-bridge watch              # one line per new message, task event or link change
agent-bridge watch --once --new # until the first new event (or --timeout), then stop

Tools, and a two-way Claude Code channel

The plugin brings an MCP server (.mcp.json, lib/integrate/mcp.sh and its PowerShell twin), registered with Claude Code when the plugin is installed: nothing to add by hand. Its tools let the session's agent talk to agents on the other machines without the command line:

Tool Does
send_message a message to a session on a peer (to, request, thread, priority, machine, expires_minutes)
reply answer a message: reply, status or done
read_inbox the messages here, or one by id (under the peer-content header)
submit_task, task_update, task_status give a task, move one along (accept ... done, fail, cancel, note, reassign), see it
sessions the agent sessions live on every machine, or one
notify_when_idle one notice back when a session on a peer next goes idle or ends
project_log add an entry to the project log (text, kind), or read it (since)
digest what needs someone, one line each

None runs a command, releases held mail or answers a permission prompt: jobs, run and sync stay with the CLI.

The same server is a Claude Code channel (a research preview there). Started as one, it pushes what watch prints into the session as events, with the message's id, kind and sender as attributes, so the agent answers with reply straight from the event:

<channel source="agent-bridge" event="msg" id="20261203T101500-laptop-3f2a9c1b" kind="request"
         from_machine="laptop" from_session="feat-login" priority="high">msg id=... subject="..."</channel>

To have it, start Claude Code with the plugin as a channel; a channel that isn't on Anthropic's list needs the development flag:

claude --dangerously-load-development-channels plugin:agent-bridge@<your marketplace>

Nothing else to set: the monitors and the channel both look at how the session was started, and exactly one of them delivers (the channel in a session started that way, the monitors in any other), so nothing arrives twice and nothing is missed. "watch": {"channel": true} or false in your own config decides it instead. The channel doesn't take Claude Code's permission requests: a message from another machine is never your approval. Channels need a claude.ai or Console sign-in (not Bedrock, Vertex or Foundry), and a Team or Enterprise organization must have them switched on. A registration made by hand before 0.12 (claude mcp add ... agent-bridge channel) runs the same server.

"watch": {"auto": false} silences the monitor in a project. It goes in your own files (the user config, or the project's untracked .agent-bridge.local.json): the shared .agent-bridge.json can't set it.

Saying what you're doing: status

agent-bridge status --set "porting the config loader (feat-paths)"
agent-bridge buildbox status     # the peer's load, your jobs there, and what each agent there is doing
agent-bridge status --clear

The who= lines in a peer's status are what its agents published, with how long ago; a line older than two hours is marked stale.

Where it's kept

Each machine has one mailbox per clone of the project, in the clone's own git folder: .git/agent-bridge-mail/ (for a worktree, its main checkout's). Git never tracks or cleans that folder, so git clean -fdx leaves queued messages and task logs alone. A mailbox from before 0.5, in .claude/agent-bridge/, is brought over at the first command, with one line saying so. In it: outbox/<peer>/, inbox/, sent/, archive/, tasks/<id>.events (every event of a task, from which its state is folded), status/, rejected/ with rejected.log (what arrived here and isn't a message for this machine, and why), and refused/ with refused.log (this machine's messages another one wouldn't take), subscriptions/ (sessions on other machines waiting for a notice from one here), deferred/ with deferred.log (threads the loop guard paused), repeats/ with repeats.log and chains/ (the loop guard's counts), log/ (the project log, and each session's .seen-<session> marker), waiting/<peer>/ with waiting.log (tasks waiting for others to be done) and .ver-<peer> (the version each peer's last exchange reported). Once a day, mail filed away or sent more than 30 days ago is packed one line each into archive/<YYYYMM>.jsonl and sent/<YYYYMM>.jsonl (its bytes as they were, so its signature still checks; read <id> still finds it), so the folders don't grow without end. Job logs, bundles in transit and build folders are not mail: they stay in <main checkout>/.claude/agent-bridge/, which is refused when a repository tracks files in it (Security).

The message format, the delivery steps and the task folding rules, for anyone writing a tool against them: skills/agent-bridge/references/protocol.md.

Edit this page on GitHub →