Skip to content

Commit 1dfffb9

Browse files
author
wenqiang.xu
committed
dev
Signed-off-by: wenqiang.xu <wenqiang.xu@okg.com>
1 parent c2dd6fc commit 1dfffb9

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

docs/what.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,26 @@ Running multiple Agents? They need to talk to each other. mq9 handles it — rel
99

1010
mq9 is async messaging infrastructure built specifically for Agent-to-Agent communication. Give each Agent a mailbox. Send messages to any Agent, online or not. Messages are stored and delivered when the recipient is ready. One binary to run, any NATS client to use.
1111

12+
## Why a mailbox?
13+
14+
Agents are not services. A service runs continuously and holds a stable address. An Agent spins up for a task, does its work, and disappears. Its identity is temporary. Its communication needs are temporary too.
15+
16+
This changes how you should think about addressing. A permanent address assigned to an ephemeral process is a mismatch — the address outlives the Agent, or worse, gets reused in ways that cause confusion. The right model is different: **communication should be scoped to the task, not the Agent.**
17+
18+
In mq9, an Agent requests a mailbox whenever it needs one. For each task, for each communication concern, create a mailbox. Share the `mail_id` with whoever needs to reach you. When the task ends, let the mailbox expire — it cleans itself up automatically via TTL. No deregistration, no cleanup code, no lingering state.
19+
20+
This means:
21+
22+
- An Agent handling five parallel tasks can have five mailboxes — one per task, completely isolated.
23+
- An Agent can have separate mailboxes for task assignments, status broadcasts, and capability announcements.
24+
- When an Agent restarts, it creates a fresh mailbox. Old messages don't bleed into a new execution context.
25+
26+
Mailboxes are cheap. Request as many as you need. The lifecycle is automatic. This is not a workaround — it's a design decision built around how Agents actually behave.
27+
1228
## The eight scenarios mq9 solves
1329

30+
> The subjects below omit the `$mq9.AI.` prefix for readability. Full subjects: `$mq9.AI.INBOX.{mail_id}.{priority}`, `$mq9.AI.BROADCAST.{domain}.{event}`, etc.
31+
1432
### 1. Sub-Agent sends result to parent {#scenario-1}
1533

1634
**Today:** Parent opens an HTTP server and waits. Sub-Agent calls back when done. If the parent restarts mid-task, the callback has nowhere to go. If the sub-Agent finishes while the parent is restarting, the result is lost.
@@ -41,7 +59,7 @@ mq9 is async messaging infrastructure built specifically for Agent-to-Agent comm
4159

4260
**The problem:** Pub/sub with no persistence is fire-and-forget. Adding persistence adds complexity.
4361

44-
**With mq9:** Publish to `BROADCAST.system.anomaly`. Any Agent subscribed with a wildcard (`BROADCAST.system.*`) receives it. Handlers that were offline get the message when they reconnect via `MAILBOX.QUERY`. Persistence is built in — no extra configuration.
62+
**With mq9:** Publish to `BROADCAST.system.anomaly`. Any Agent subscribed with a wildcard (`BROADCAST.system.*`) receives it in real time. Note: BROADCAST is fire-and-forget — if a handler is offline when the alert fires, it misses it. For critical alerts that must survive offline handlers, send to their `INBOX` directly instead.
4563

4664
### 5. Cloud sends command to offline edge device {#scenario-5}
4765

@@ -75,22 +93,6 @@ mq9 is async messaging infrastructure built specifically for Agent-to-Agent comm
7593

7694
**With mq9:** Agent publishes to `BROADCAST.system.capability` on startup with its skill list and `reply_to` address. Orchestrators subscribed to this channel build a live index. When an Agent goes offline (TTL expires), it disappears from the index naturally. No registry to maintain.
7795

78-
## Why a mailbox?
79-
80-
Agents are not services. A service runs continuously and holds a stable address. An Agent spins up for a task, does its work, and disappears. Its identity is temporary. Its communication needs are temporary too.
81-
82-
This changes how you should think about addressing. A permanent address assigned to an ephemeral process is a mismatch — the address outlives the Agent, or worse, gets reused in ways that cause confusion. The right model is different: **communication should be scoped to the task, not the Agent.**
83-
84-
In mq9, an Agent requests a mailbox whenever it needs one. For each task, for each communication concern, create a mailbox. Share the `mail_id` with whoever needs to reach you. When the task ends, let the mailbox expire — it cleans itself up automatically via TTL. No deregistration, no cleanup code, no lingering state.
85-
86-
This means:
87-
88-
- An Agent handling five parallel tasks can have five mailboxes — one per task, completely isolated.
89-
- An Agent can have separate mailboxes for task assignments, status broadcasts, and capability announcements.
90-
- When an Agent restarts, it creates a fresh mailbox. Old messages don't bleed into a new execution context.
91-
92-
Mailboxes are cheap. Request as many as you need. The lifecycle is automatic. This is not a workaround — it's a design decision built around how Agents actually behave.
93-
9496
## How it works
9597

9698
Every Agent gets a **mailbox** — temporary, task-scoped, built for how Agents actually work.
@@ -142,6 +144,8 @@ await nc.publish("$mq9.AI.INBOX.m-target-001.normal",
142144

143145
## Quick start
144146

147+
> Requires the NATS CLI — `brew install nats-io/nats-tools/nats` or see [nats.io](https://nats.io/download/).
148+
145149
```bash
146150
# Run mq9
147151
docker run -d -p 4222:4222 robustmq/robustmq:latest

0 commit comments

Comments
 (0)