duet-agents
Run Claude Code, Codex CLI, Kimi CLI, and OpenCode as a visible
mesh of agents in tmux (macOS/Linux) or psmux (Windows). Every agent can
message every other agent directly — to divide work, debate an approach, or
cross-check one another. There is no leader and no election; the agent the
task was given to coordinates by convention.
This repository ships an npx installer (npx github:JonathanRosado/duet-agents) that sets the mesh up for Claude Code,
Codex CLI, Kimi CLI, and OpenCode alike — any of the four can install it,
update it, and initiate a session. Installing adds a duet command to each
selected CLI, which creates the panes, a durable brief, per-recipient message
queues, and one delivery daemon.
Platform status: the v4 leaderless mesh ships on
macOS/Linux (Bash + tmux) and Windows (PowerShell + psmux). Native
harness-session pairing/rejoin for Claude, Codex, and Kimi currently ships
on the Bash/tmux path. OpenCode is a full fresh-session initiator and peer on
both platforms, but its native pairing/rejoin is not supported.
Steering a message into a busy Kimi peer's running turn — instead of only
ever landing in its composer — ships on Windows; the ref= envelope field
it depends on is emitted on both platforms, but the steer logic itself is
not yet ported to Bash/tmux.
┌──────── one delivery daemon (per session) ────────┐
│ per-recipient FIFO inboxes · at-least-once │
└──▲──────────▲──────────▲──────────▲────────────────┘
│ │ │ │
claude ◀───▶ codex-1 ◀─▶ kimi-1 ◀─▶ opencode-1
any agent messages any agent by name, or broadcasts to `all`
Duet is deliberately small. v4 removed the leadership, election, failover,
crash recovery, admission control, and cross-session fencing that had accreted
over earlier versions. What remains is one job done well: reliably moving a
message from one agent's queue into another agent's prompt.
Why queues instead of screen-scraping
A terminal pane is a mutable display, not a reliable message channel. Duet does
not reconstruct agent responses by scraping pane output. A send atomically
publishes the message to a per-recipient inbox, and one delivery daemon injects
it into the recipient's normal prompt through the platform paste transport. On
Windows, the daemon reads the pane only to identify bounded UI transitions:
paste landing, composer state, a harness-owned pending row, and a rendered
receipt. Agent content travels in the queued payload, never through
capture-pane output.
The transport's properties:
- Serialized, fair delivery. Each recipient has a FIFO inbox. The daemon
makes at most one bounded attempt per recipient per pass, so one stuck
recipient never blocks the others. Interrupts take priority within a queue.
- At-least-once + dedup. Every payload carries a session ID and a stable
message ID. A recipient suppresses a repeated ID; agents are told to ignore a
duplicate. Exactly-once is not claimed.
- Terminal states. In a live session, a message is archived delivered (or
rejected — its envelope is malformed and it is moved to
rejected/ with a
reason), or its recipient is surfaced as dead (pane gone) or blocked
(fenced after a wedged composer, an ambiguous submit, or repeated non-landing)
and its queued head is no longer attempted — never silent limbo. A single
peer's failure is recipient-scoped and never sinks the mesh. (The documented
exceptions are a send racing an immediate end, and a discarded crashed
session — see Ending and No recovery.)
- Harness-aware submission. After the Windows transport reports
WIRE_SENT, the daemon attempts Enter even when a busy/redrawing pane hides
the landing marker. It never repastes an uncertain message. Claude, Codex,
and OpenCode use their native deferred queues; Kimi uses its declared C-s
steer key when an exact ref= row is paired with its pending-queue hint.
OpenCode declares no steer key: Enter queues while it is busy and the TUI
drains that queue itself. Escape is OpenCode's explicit interrupt and Duet
never sends it automatically; Escape is never a submit or steer key.
OpenCode collapsed-paste markers such as [Pasted ~3 lines] are recognized
in the same cursor-scoped composer check.
- Proof before archive. A Windows envelope moves to
delivered/ only after
one of three named UI proofs: native-composer-cleared,
native-transcript-rendered, or steer-owned-row-consumed. An ambiguous
submit remains at the queue head and resumes in SubmitOnly or SteerOnly
phase; it is never reported delivered merely because the composer cleared.
- Protocol parity, steering staged by platform. Windows and POSIX envelopes
both put the immutable per-recipient sequence in an early
ref= field.