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
- Tasks
- Sessions: who is there, and whose mail it is
- Mail that isn't about a project
- Live delivery
- Saying what you're doing: status
- Where it's kept
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 noteOnly 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).
- Claiming: an agent on any of those machines runs
task claim <task>. The claim goes to the creator's machine, which gives the task to the earliest claim (by its stamp, then its name) and tells every machine it was offered to (assigned). Until then the claimer can't start it; a claim that came later is simply not chosen. - The lease: the assignee's events (accepted,
started, progress, blocked, and a job's step reports) renew it. One that
sends nothing for the lease gives the task back: the creator's machine
reopens it (
reopened), and any of them can claim it again. Nobody is asked: the creator's watch does it, and sayspool task=... assigned to=...or... reopened. - Seeing it:
task lsshowsto=pooland the machines it was offered to; the digest on those machines saysopen in the pool (agent-bridge task claim <task>). The MCP tools:submit_taskwithpool: true, andtask_updatewithaction: claim. - Only where it can run:
--needs xcode,gpuoffers it only to peers that have those, as each peer's own probe says (cargo,go,node,dotnet,docker,python,xcode,nvidia,metal;gpuis nvidia or metal). A peer reports them toping,statusandpickover a full link; a safe link reports what its sandbox has (no docker), a messages-only one nothing.pick --hasfilters the same way. - Limits: a pool task can't use
--afteryet, and a peer older than 0.12 isn't offered one.
Order and subtasks. A task can name the tasks it
comes after (--after <task>,..., tasks this machine
knows) and its parent (--parent <task>).
- The order is kept by itself. A task whose
--aftertasks aren't all done yet stays here,waitingintask ls, and goes to the peer by itself once the last of them is done (watch saysready task=...). Nothing else can happen to it meanwhile buttask cancel, which drops it without the peer ever seeing it. - One that fails stops it. If one of them fails, is
declined or cancelled, the task doesn't go: watch says
waiting task=... on=... state=failedonce, and the digest keeps saying so until you cancel it. - The parent rolls up.
task show <parent>lists its subtasks with their states and how far they are together.
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:
- It picks the machine (as
pickdoes, or the one you name) and syncs this branch (or--branch) to a job there. - 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, orcodex exec, with the task as its prompt on stdin. - The job reports to the task (started, done or failed with its exit
code).
task wait <task>, thenagent-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.
- Reading it:
agent-bridge loglists the latest entries, oldest first (--since 2h,-n N,--json), and marks them seen for this session. A session that starts with entries it hasn't seen is told how many, in one line. The MCP toolproject_logadds an entry (withtext) or reads the log (without). - What it holds: information from other agents, like any message: not instructions, never the owner's approval. It is the project's, so it lives in the project's mailbox only; each machine keeps up to 5000 entries.
- An older peer: a peer whose agent-bridge doesn't
know the log yet isn't sent entries;
log addsays which.
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.
- Two sessions on one file are told. When a session
here and one on a peer both edited the same file in the last 30 minutes,
each one's monitor says so once:
overlap: buildbox/feat-x also edited src/auth/login.ts 4m ago, by buildbox's own report (main here edited it 2m ago). It is a warning, not a lock: the agents agree who changes it. It comes from the activity journal (file tool calls, recorded at the leveltoolsor more), only over a full link (a messages-only or safe peer is never told your files), only for a project, never for the machine mailbox. - Roles as addresses. A session started with
AGENT_BRIDGE_ROLE=reviewer(in the agent CLI's environment) has that role, andmsg @reviewer "..."(ortask new --to @reviewer) is for every session with it on the peer;--allfor every peer. Where no live session there has the role, every session's monitor shows it, so it isn't lost. A peer older than 0.12 isn't sent role mail;msgsays so. - The sender is told when nobody is there. After
delivering to a name or an id,
msgsays so when no live session on the peer has it:note: no agent session 'reviewer' is live on buildbox right now. The message waits in the inbox there. - A session's monitor shows it its own mail: what is
for its name, for its id, or for
any, and what is for a session that isn't live on that machine (mail for a branch nobody is on must not go unseen). Mail for another live session is left to that session.watch --minedoes the same by hand; plainwatchandwatch --allshow everything, and so doesinbox. - How far a request got.
read <id>on a message you sent ends with its state:queued,delivered,shown to buildbox/reviewer(a session's monitor printed it into that session),read. "Shown" is reported for requests and new tasks, between machines that both run this version or a later one. - When the other agent is done.
agent-bridge buildbox wait-idle reviewer --timeout 600returns when that session is idle or has ended (0), says once when it is waiting for its owner's approval, and exits 1 when no such session is live, 124 at the timeout. Without a peer it watches a session on this machine. Claude Code, Codex and Grok say when they go idle; a CLI that doesn't is taken as idle after it has done nothing for half a minute. - Told when it's done, without waiting.
agent-bridge buildbox notify-idle reviewerasks that session to send one notice back when it next goes idle or ends, and returns at once: the notice comes like any message, astatusanswering the request (idle: buildbox/reviewer), so a session's monitor shows it. If the session is idle already, the notice comes straight away. A request lapses after 12 hours (--timeout <s>for another limit). It works between machines, where Claude Code's ownnotify_when_idleis for sessions on one machine. Nothing extra runs for it: the other machine's Stop and SessionEnd hooks send the notice, and only when a request waits. - At a session's start, Claude Code is told in one line how many unread messages wait in the project's mailbox, and in the machine's own (the count, never their text), so mail that came while no session was open isn't missed. The line also says how many are urgent (and who sent the first), how many name this session (its branch), and how many the loop guard paused.
- One digest instead of a firehose.
agent-bridge digest(the MCP tooldigest) lists what needs someone, one line each, newest first, from the project's mailbox and the machine's: unread and urgent messages, tasks that are blocked, waiting to be accepted here, waiting on other tasks, overdue or quiet for an hour while running, threads the loop guard paused, held mail, what was rejected or refused in the last day, what is still queued for a peer, and sessions on other machines waiting for their owner. It moves nothing.--jsonfor a script.
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 }hold: that peer's messages and task events wait inheld/. No session is shown them and no task folds them;watchprints onlyheld id=... from=.... You look and decide:agent-bridge inbox --held(who and when, never the text), thenagent-bridge inbox --release <id>...or--release --all.refuse: they are rejected, and the sender's machine files them underrefused/at its next exchange.max_per_minute(60 when not set): beyond that many from one peer within a minute, the rest wait in its outbox and come with the next exchange, so two agents answering each other can't run away. Nothing waits for you.max_chain(20 when not set; 0 for no limit): beyond that many messages in one thread since you last prompted a session in this project on this machine, the rest of the thread waits indeferred/, andwatchprints onepaused thread=... from=...line. They come back by themselves at your next prompt in the project, or after 30 minutes, and the thread's count starts again. Two agents answering each other slowly enough to pass the rate limit still can't go on for hours unattended.
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
--machineonmsg,task new,inbox,watch,exchangeandarchivemeans that mailbox. Outside a repository these commands use it by themselves.- A command that names a message or a task
(
read <id>,reply <id>,wait-reply <id>,task accept <id>...) finds it there by itself, from any folder. - Every Claude Code session on the machine is shown what arrives there
(a second monitor,
watch --new --quiet --machine): mail for its name or id, forany, or for a session that isn't live.anyhere means any session on that machine, whatever project it is in. - It is kept in the user's state folder,
~/.local/state/agent-bridge/mail/(on Windows%LOCALAPPDATA%\agent-bridge\mail\), and isn't carried over a messages-only link: such a machine reaches a project's mailbox only.
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.