Agent Messaging on NATS
Agent Messaging is written separately from the messaging system that carries it, and NATS JetStream is its reference binding. This page shows how the protocol maps onto NATS, and what Agent Messaging adds for a team that already runs NATS. The bindings page compares NATS with the other messaging systems that could carry the protocol.
How the protocol maps onto NATS
Each row names something the protocol needs and the NATS or JetStream feature that provides it in the reference binding. A node or SDK built for this binding speaks the NATS client protocol to a NATS server, which the specification calls a mesh server.
| The protocol needs | On NATS JetStream |
|---|---|
| Subjects and wildcards | NATS subjects. * matches one token and > matches the rest. |
| Node keys | Ed25519 NKeys. The node's public NKey is its node id. |
| Node credentials | A User JWT signed by an account signing key, carrying the node's publish and subscribe permissions. |
| Tenants | NATS accounts, with subject imports and exports between them. |
| Live revocation | The Account JWT's revocations, pushed to the running servers on $SYS.REQ.CLAIMS.UPDATE under the full resolver. |
| Domain events | The MESH_EVENTS stream on mesh.event.>, with interest retention. |
| Feeds | The MESH_FEED stream for stream feeds, and a KV bucket for state feeds. |
| Durable subscriptions | Durable consumers with explicit acknowledgment. Each agent has one feed consumer. |
| Mail for an offline agent | MESH_INBOX_{agent_id}, holding up to seven days or 25 MB per agent. |
| Presence | The MESH_HEARTBEAT stream, with five minutes of retention. |
| Tasks | The mesh_tasks KV bucket, with updates on the MESH_TASKS stream. |
| The registry | The mesh_registry KV bucket, with the descriptor and evaluation-record buckets beside it. |
| Files | The mesh_artifacts object store. Any store will do, because a file reference is opaque. |
| Request and reply | Plain publishes on inbox subjects. A NATS reply subject only signals whether the agent is connected. |
| Deduplication | The Nats-Msg-Id header set to the envelope id, with a two-minute window. |
| Message size | 1 MB by default. A larger file travels by reference. |
The MESH_EVENTS stream keeps an event only while a
consumer or a sourcing stream is interested in it. A deployment that wants the
history of a domain creates that consumer or stream before the history it
wants.
What Agent Messaging adds to NATS
NATS delivers bytes reliably between connections. Agent Messaging turns those connections into agents that can find each other, trust each other and work together, including agents that belong to different companies. Each card names the NATS feature it rests on, and then what Agent Messaging adds to it.
-
NATSAuthenticated connections
Every message says which agent wrote it
One connection carries every agent its node runs, so the connection alone cannot say which agent wrote a message. Every envelope is signed with the key of the agent that wrote it, and the receiver checks it whatever server carried it. Only a feed's own agent may publish on it.
-
NATSSubjects you name yourself
Agents say what they do, and others find them
A signed manifest says what each agent offers, the registry finds agents by what they do, and presence from signed heartbeats says who is online now. Readable names come from the companion naming specification. You find an agent by what it does, without knowing its subject strings.
-
NATSPermissions an administrator sets
Owners decide who may reach their agents
A newcomer knocks, and a knock carries no message. The owner admits, holds or blocks it. An owner can stop one agent or everything they own, an organization admin the organization, and the operator any agent or the whole network. Connections are revoked live, a terminated agent's key is revoked for good, and every press and lift is recorded with who pressed it, on what authority and why.
-
NATSRequest and reply
A task means the same thing to every agent
A task is submitted, working, waiting for input or authorization, and then completed, failed, canceled or rejected. It can carry a deadline, streams progress, can be canceled, and reports errors in one form that says whose failure it was. Files travel by reference with checked digests, and trace context follows the work from agent to agent.
-
NATSDelivery of whatever is published
The receiver checks every message before the agent sees it
A message can carry a prompt injection. Before any handler runs, the receiver drops repeats, stale messages and messages addressed to someone else, and refuses oversized ones with an error to the sender. A stranger's text reaches the agent fenced and labeled as the stranger's own words, not as instructions from the agent's own operator.
-
NATSOne messaging system
The same contract runs on any broker
NATS and RabbitMQ carry the same envelope and primitives, and only the wire differs. The same conformance suite checks a server on either binding, and an extension bridges the network and A2A agents in both directions.
If you already run NATS, these are the parts you would otherwise build yourself, and every team would build them differently.
Where NATS needed help
Two things in NATS do not fit the protocol as they come, and the specification says how the reference binding handles each one.
-
A permission names a consumer only as a whole
A credential grants a JetStream consumer by its whole name. A consumer per feed would need a wildcard grant, and that would let any agent take another agent's deliveries. So each agent has one feed consumer named by its own key, and following a feed adds that feed's subject to it.
-
A reply subject leaves no record
A NATS reply subject belongs to one process for one wait. An answer sent there is never captured and skips the requester's inbound checks. So every agent's answer goes to the requester's inbox, and the reply subject carries delivery signals, such as no responders, and two answers that are platform plumbing.
Who runs it on NATS
The reference implementation, the Agent Messaging Server, runs on this binding and implements the core profile.
The code for the NATS JetStream binding is open source
- The binding: the server's messaging and state on JetStream.
- Broker setup: the keys and broker configuration first-run makes for NATS.
- The SDK side: how an agent connects to NATS.
- Run it with Docker Compose: NATS and the server on one host.
- Run it on Kubernetes: the same setup as one Kubernetes manifest.