MeshyChat 為何以簽名訊息匯流排協調智能體,而非依賴聊天記錄
Why my agents talk over a signed message bus, not a chat log
Andrew Demczuk 以 MIT 授權開源 MeshyChat,讓不同機器上的智能體工作階段透過簽名訊息匯流排協作,而非依賴聊天記錄。系統由 Django 和 PostgreSQL 16 伺服器、Python CLI 及每台主機的 postbox daemon 組成,本身不執行模型,並提供簽名驗證、待回覆追蹤和按執行環境喚醒 CLI 的機制。
I keep about 25 persistent agent sessions (Claude Code, Codex, Kimi, Antigravity) running across four machines. Most stay scoped to a repository, a review gate, or a watchdog so they do not cold-start on every task; it is not 25 agents writing code at once.
For months, coordinating them meant copy-pasting text between terminal windows. That breaks down once work spans machines, operating systems, and vendor subscription plans. After leaving the OpenClaw dev team, I wanted a message layer no single vendor owns, where every ask stays tracked until answered.
I open-sourced MeshyChat under the MIT licence. It is a Django and PostgreSQL 16 server, a Python CLI (meshy_node), and a per-host postbox daemon (tools/postbox/). It runs no model itself and connects standalone agent CLIs you already run.
Why not an in-process agent framework
Frameworks like LangGraph or CrewAI build an agent graph out of functions inside one Python runtime. That fits a single program calling APIs in a loop, not an interactive Codex session on one machine talking to Claude Code on another and Kimi on a third, each on its own plan and filesystem.
MeshyChat gives each session a key pair and mailbox. A session can restart, move hosts, or hit a quota reset without losing threads or open asks.
The three pieces
1. Signed messages, PostgreSQL RLS, and operator_words
Each node generates an Ed25519 key pair locally (meshy_node mint) and redeems a single-use pairing code. The private key stays in the node's state file; the server holds only the public key.
Requests and messages use RFC 8785 canonical JSON (rfc8785) signed with Ed25519 and checked by PyNaCl verify_strict in apps/crypto/primitives.py, which rejects small-order public keys and non-canonical scalars. The server signs its read responses too, so clients verify both author and server before showing text.
PostgreSQL 16 enforces authorization and history through plain SQL migrations (sql/ and sql_meshychat/):
-
Row-level security.
apps/core/rls.pytracks 26 policies over 12 tables. Every request runsSET ROLE meshychat_appand bindsapp.current_peer_id(plusapp.server_internalfor internal paths) local to the transaction so pooled connections cannot leak state. -
Append-only history. Stored messages in
shared_memoryhave aBEFORE UPDATEimmutability trigger (shared_memory_enforce_immutabilityinsql/028_shared_memory_v02.sql). Edits add a new version and retire the prior head (is_headfrom true to false) rather than overwriting rows. Audit tables (invocation_frames,admin_audit_log) are also append-only, while namespace grants live inshared_memory_grantunder forced RLS (updatable only to mark revocation). -
Authority separation (
operator_words). Peer message bodies are always untrusted data. Only pinned operator voice peer IDs can write theoperator_wordsfield (1 to 20 strings onshared/mesh-chat), and the server refuses it from any other writer (apps/memoryskills/validation.py). An opt-indirectivefield exists under similar roster rules (THREAT-MODEL.md).
2. Tracked asks (owed and awaiting)
In a scrollback chat log, an unanswered question disappears in minutes. Sending with --expects-reply keeps the message on the recipient's owed queue and the sender's awaiting queue until answered with --in-reply-to <key> and settled with --closes <key> (replies to question messages auto-close after a verified read unless --keep-open is passed).
A background job (mesh_edges_catch_up) projects message, reply, close, and owes_ack edges into mesh_edges, so nodes query open asks without scanning message bodies.
3. The per-host postbox wake
Polling inside an agent prompt burns context and misses mail when idle. On each host, tools/postbox/postbox.py runs meshy_node listen --monitor over WebSocket, catches up from the node's cursor after disconnects, fsyncs notices to a local spool, and wakes each CLI according to its runtime (tools/postbox/README.md):
-
Claude Code:
meshy_channel.pypushes<channel source="meshy">events into the session. -
Codex: the postbox queues notices via
codex queue --thread <target> --message <notice>. -
Kimi and Antigravity:
wait_next.py <identity>runs in the background, exits with the arriving key andreply_withcommand, and re-arms after each wake.
Pushes carry routing metadata and the meshy_node read command rather than body text, so the session fetches and verifies the signed message itself.
Patterns that held up
-
Overnight watchdog. Built on
owed,awaiting, andmesh_presence, a periodic check flags sessions that went quiet while owing an answer so stalled work is nudged or reassigned. -
Cross-vendor PR review gate.
meshy_node review-receiptandgate-checkverify a clean review on the exact PR head SHA before merge, such as Codex reviewing Claude Code's commit. -
Holding deadline or scope changes. Agent proposals that slip a date or cut scope stay unapproved until a human signs off via
operator_words.
Delivery latency on one node
The README reports one week of telemetry from python -m tools.postbox.latency across 1,431 messages on a single node (13 to 20 November 2026), not a synthetic load test:
- Sent to landed in local spool: 1.2 s median, 2.2 s 95th percentile.
- Spooled to handed to running session: 6 s median, about 19 min 95th percentile.
- Handed over to agent reading it: 17.5 s median, 2.7 min 95th percentile.
1,412 of 1,431 messages were handed on and 1,322 were read, with zero skipped wakes. The 19-minute 95th percentile in the middle stage is the coding session finishing its active turn before taking new mail, not server delay.
What broke in practice
-
Stale presence. A crashed session used to appear active until TTL expiry;
apps/dashboard/queries.pynow flags unrefreshed or expired states aspresence_stale. -
Silent listener deaths. On 1 October 2026, two listeners died while the 5-minute inbox reconciler kept advancing
last_poll_ok_atfor five hours. That led topostbox.py --liveness(checking live PIDs) andtools/postbox/unsurfaced.pyto track notices delayed between dispatch and read. - Quota resets. Hitting plan limits mid-task is routine; having another vendor's session on the same bus lets work move instead of waiting.
Early status and known gaps
From RELEASE-NOTES.md, this first public cut has explicit gaps:
- The README's 3D graph GIF shows an internal operator UI that is not in this release (this cut is server, CLI, and postbox).
- Docs under
docs/still carry placeholders (sampleco,example.com,C:/Users/user), two CLI defaults still namesampleco, and extraMESHYCHAT_*variables live only inmeshychat/settings.py. - The hosted task-board adapter (
tools/meshy_node/board_{tasks,queue,claim,dispatch}.py) is stubbed;apps/boardis included. - This tree is not wire-compatible with the original deployment because tables, headers, and signing domains were renamed.
- The full suite has about 12,200 tests (PostgreSQL 16 required). A three-shard run before the public commit had 13 failures of 12,168: 4 migration rename tests in
tests/test_p2_meshychat_names.py(now deselected intests/public_cut_deselect.txt, leaving three grant and RLS checks unverified here), 3 needing ameshychat_ownerDB role absent on that fresh DB, 1 expecting a committed tree, and 5 timing-sensitive under parallel load (4 passed alone).
Under MIT, you can lift apps/crypto/primitives.py, the owed/awaiting SQL model, operator_words, or tools/postbox/ on their own.
Repository: https://github.com/ademczuk/MeshyChat
來源:DEV Community · dev.to
