agent-bridge

Documentation

Configuration

Pairing writes the configuration for you; this page is for adjusting it, or writing it by hand.

The three files

Three JSON files are merged, later ones winning key by key (objects merge, other values replace):

File What it's for
1 $AGENT_BRIDGE_CONFIG, else ~/.config/agent-bridge/peers.json (on Windows too: %USERPROFILE%\.config\agent-bridge\peers.json) This machine and its peers. Personal: never commit it. Pairing writes it.
2 <repo>/.agent-bridge.json Project settings to share with everyone who uses the project; commit it if you like.
3 <repo>/.agent-bridge.local.json Your own overrides for this project; anything file 1 can hold. Read only while git doesn't track it.

A cloned repository is not trusted with your link. File 2 may set only presets, env, default_peer, default_branch, fetch_origin, project, and presets and env under peers that file 1 already has. Anything else in it (an ssh alias, a repo path, this machine's name, the way back) is ignored, with one warning. A committed file 3 is ignored too.

agent-bridge config shows the merged result, every peer and the files it came from; config --json prints the merged JSON.

An example

~/.config/agent-bridge/peers.json on a laptop with a Windows build machine and a Linux box:

{
  "self": "laptop",
  "default_peer": "buildbox",
  "peers": {
    "buildbox": {
      "ssh": "bridge-buildbox",
      "os": "windows",
      "name": "buildbox.local",
      "addresses": ["192.0.2.20"],
      "repo": "C:/src/{project}",
      "build_dir": "D:/builds",
      "jobs": 8,
      "max_jobs": 2,
      "allowed_from": ["192.0.2.0/24"]
    },
    "linuxbox": {
      "ssh": "bridge-linuxbox",
      "os": "linux",
      "repos": { "my-app": "~/work/my-app" },
      "weight": 2
    }
  }
}

<repo>/.agent-bridge.json, shared by the project:

{
  "project": "my-app",
  "env": { "RUST_BACKTRACE": "1" },
  "presets": {
    "test": "cargo test --workspace --locked",
    "check": ["cargo clippy --workspace --all-targets --locked -- -D warnings", "cargo test --workspace --locked"]
  },
  "peers": { "buildbox": { "presets": { "installer": "cargo build --release --locked" } } }
}

More in examples/peers.example.json and examples/agent-bridge.example.json.

Every key

Top level

Key Meaning
self This machine's name (see Names). Default: the host name, lowercased. Pairing saves it.
serve For machines paired with this one for messages only: {"repos": ["<path>", ...]} are the clones offered to them first, and "search": false offers no other (default: this machine's clone of the project is looked for in the usual source folders, by the project's first commit).
default_peer The peer when a command names none. With a single peer, it's that one.
project The project's name, for {project} in repo and the keys of repos. Default: the repo folder's name.
default_branch The remote's branch update-checkout brings a peer to. Default: origin/HEAD, else main, else master.
fetch_origin false: don't git fetch origin on this machine before update-checkout. Default: try, with prompts off and a time limit; nothing depends on it working.
env Environment variables for every job, on every peer.
presets Named commands for job --preset: a string (one step) or a list (one step each), written in the peer's shell.
activity.level (user file) What the activity journal keeps of agent sessions: off, sessions (state only), tools (and each tool call: its name and a short, redacted detail), prompts (and the first line of each prompt, redacted). Default: prompts once this machine has a peer, sessions before.
inbox.from (your own files) What this machine does with each peer's messages: {"buildbox": "hold"}. accept (the default), hold (they wait for you: agent-bridge inbox --held, inbox --release <id>), or refuse (rejected, and the sender is told).
inbox.max_per_minute (your own files) How many messages a minute are taken from one peer. Beyond that the rest wait in its outbox and come with the next exchange, so two agents answering each other can't run away. Not set: 60.
pool.max_claims (your own files) How many pool tasks one session may hold at once, claimed or given to it; task claim refuses beyond that. Not set: 3. 0: no limit.
inbox.max_chain (your own files) How many messages one thread may bring since you last prompted a session in the project; beyond that the rest wait in deferred/ and come by themselves at your next prompt or after 30 minutes. Not set: 20. 0: no limit.
watch.auto (your own files) false: the plugin's monitor (watch --quiet) stays silent in this project. The shared .agent-bridge.json can't set it.
watch.channel (your own files) Not set (the usual): the Claude Code channel delivers in a session started with agent-bridge as a channel, and the monitors in any other. true or false decides it instead.
fleet.accept (user file) true: while advertise runs, answer a fleet member's pair --fleet by itself. Set with agent-bridge fleet accept on|off.
fleet.network (user file) Where fleet joiners are let in from, e.g. 192.0.2.0/24 (sshd must allow it). Without it, the joiner's own addresses.

Per peer (peers.<name>)

Key Meaning
ssh The Host alias in ~/.ssh/config. Required.
os windows, macos or linux. Required.
name The peer's mDNS or DNS name (buildbox.local), used instead of the ssh config's HostName. Optional: the name in the ssh config works the same.
addresses Addresses to try, in order, when the name doesn't resolve (after the last one that worked, kept in ~/.cache/agent-bridge/<peer>.addr, on Windows %LOCALAPPDATA%\agent-bridge\<peer>.addr). The host key must be pinned under the alias (HostKeyAlias) for these to pass the host-key check.
repo The project's clone on the peer; {project} is replaced, ~/ allowed on macOS/Linux. Not needed: the clone is found by itself the first time and kept in repos.
repos Per-project paths, {"<project>": "<path>"}, winning over repo.
build_dir Where job build folders go (<build_dir>/bridge-<self>-<job>). Default: <repo>/.claude/agent-bridge/build. A shared folder is fine: only bridge-<self>-* in it is ever touched.
jobs A cap on parallel build jobs: steps get AGENT_BRIDGE_JOBS and CARGO_BUILD_JOBS. For a Windows machine that runs out of commit memory with many cores (os error 1455). cargo_jobs is read as an older name for it.
max_jobs How many jobs may run on the peer at once, from every project and machine; more wait as queued, and pick skips a full peer. Not set: no cap.
weight Your preference in pick (each point is worth 10 score points; negative to avoid a peer).
cargo_target_dir false: don't set CARGO_TARGET_DIR to the build folder for jobs.
fetch_origin false: the peer doesn't git fetch origin before a sync.
shell macOS/Linux: the shell for job steps and run. Default: the user's login shell if it's bash, zsh or sh, else bash.
env Environment variables for jobs on this peer (winning over the top-level ones).
presets Presets for this peer (winning over the top-level ones of the same name).
via Experimental and opt-in, the off-LAN path: {"ab_link": "<the peer's endpoint id>", "relay": "none" | "n0", "addr": "<ip:udp port>"}. SSH reaches the peer through ab-link dial as its ProxyCommand (the host-key pin and key login stay the same), and agent-bridge link listen on that peer lets this machine in by the same id. relay none (the default) uses no outside service and needs addr; n0 uses n0's public relays and lookup (a third party: they see ids, addresses and timing, never content). ab-link is AGENT_BRIDGE_AB_LINK, or on PATH (The link's design).
require_pq true: use only a post-quantum key exchange with this peer (ML-KEM or sntrup761 hybrids, of the ones this machine's OpenSSH has), and refuse to connect otherwise. Given on ssh's command line, never written to ~/.ssh/config (every OpenSSH on the machine reads that file, and a name one of them doesn't know breaks them all). doctor shows which key exchange the link uses either way.
back_ssh No longer used (0.7 and earlier: a way back for done messages). Done messages come by watch's long poll, so the peer needs no key into this machine; pairing removes the key from the entry.
allowed_from The addresses or networks the peer accepts this machine from (its from= and firewall rule), for doctor's check. Pairing sets it.
link "safe": this peer runs only safe jobs for this machine (messages, sync, jobs in its sandbox, logs, fetch, get; its owner ran pair <this machine> --limit safe). "messages": this peer takes only messages from this machine (it paired with --messages-only). ping notes it by itself. Messages, tasks, sessions, wait-idle and ping work; jobs, sync, run and the rest say why they don't. repo isn't needed: the peer finds its own clone.

Names

Each machine has one name, self: lowercase letters, digits and dashes, up to 24. Job worktrees on a peer are named after it (bridge-<self>-<job>) and messages come from it, so:

Environment variables

Everyday

Variable Meaning
AGENT_BRIDGE_CONFIG The user config file, instead of ~/.config/agent-bridge/peers.json.
AGENT_BRIDGE_PEER The default peer.
AGENT_BRIDGE_SELF This machine's name, instead of self.
AGENT_BRIDGE_SESSION Your name in messages (<machine>/<session>). Default: your branch, else the folder's name.

Pairing and discovery

Variable Meaning
AGENT_BRIDGE_MY_IPS The addresses this machine announces when pairing (comma-separated), instead of its LAN interfaces' (for a link over a VPN).
AGENT_BRIDGE_DISCOVERY How to find machines on the LAN: dns-sd, avahi, pwsh, or off (no discovery: pairing refuses, and the address-following step is skipped). Default: the first one available.
AGENT_BRIDGE_FLEET_KEY The fleet key file, instead of ~/.config/agent-bridge/fleet.key.
AGENT_BRIDGE_FLEET_NET Where fleet joiners are let in from, overriding fleet.network.
AGENT_BRIDGE_CLI=off In Claude Code's environment: its sessions neither put the agent-bridge command in your terminal nor keep it on the plugin's current folder (Install).
AGENT_BRIDGE_PAIR_SSHD=skip Pairing leaves this machine's SSH server alone (you manage it yourself).
AGENT_BRIDGE_PAIR_PING=skip No ping over the new link after pairing.
AGENT_BRIDGE_PAIR_NOTIFY=off No code window or notification (the code must then be read in a terminal).
AGENT_BRIDGE_UNATTENDED=1 Never open a password dialog or UAC prompt (nobody is there to answer it). advertise sets it for the fleet joins it answers.
AGENT_BRIDGE_ADMIN_SECONDS How long a password dialog may stay open (default 180).
AGENT_BRIDGE_LOOKUP_SECONDS How long a LAN lookup listens (default 3-4).
AGENT_BRIDGE_USER, AGENT_BRIDGE_HOST_KEY, AGENT_BRIDGE_SSH_DIR The user name pairing announces, the SSH host key file, and the folder instead of ~/.ssh (mostly for tests).
AGENT_BRIDGE_SSH_CONFIG An ssh config file the link uses instead of ~/.ssh/config (ssh -F; mostly for tests). On Windows agent-bridge runs the Windows OpenSSH client, not Git's own ssh (which a PowerShell started from Git Bash finds first): the one that uses the Windows ssh-agent.

The link

Variable Meaning
AGENT_BRIDGE_MUX=off No SSH connection sharing (macOS/Linux keep one connection per peer open a minute, shared by every call).
AGENT_BRIDGE_MDNS_DEBUG=1 The PowerShell mDNS responder prints what it hears (for discovery problems).

Inside a job's steps (set by agent-bridge; see Jobs): AGENT_BRIDGE_JOB, AGENT_BRIDGE_BUILD_DIR, AGENT_BRIDGE_JOBS, CARGO_TARGET_DIR, CARGO_BUILD_JOBS. A step that prints AGENT_BRIDGE_SUMMARY: <text> adds that text to its summary.

The folders follow XDG_CONFIG_HOME (the config), XDG_CACHE_HOME (the cache: job history, last addresses), XDG_STATE_HOME (the activity journal) and XDG_DATA_HOME (install-cli's link) when they are set; the paths in these pages are the defaults.

The tests use a few more (AGENT_BRIDGE_TEST_LOCAL, AGENT_BRIDGE_TEST_BASH, AGENT_BRIDGE_TEST_LOAD, AGENT_BRIDGE_TEST_HOLD, AGENT_BRIDGE_TEST_LIVE_MDNS, AGENT_BRIDGE_SSHD_ETC, AGENT_BRIDGE_MY_NETS): see Development.

Edit this page on GitHub →