A practical guide to how AI agents communicate: transports, protocols, message formats, discovery, and the failure modes to avoid before your agents ship.
Every agent demo works until you need two of them to work together. A single agent can call tools and produce output, but real systems — a procurement agent checking with a budget agent before approving spend, a monitoring agent waking a remediation agent at 3 a.m. — require agents to exchange messages that each side actually understands.
Here's how agent-to-agent communication works in practice: the layers involved, message formats that hold up under load, and the failure modes that appear once you're past the demo stage.
1. Transport. The bytes on the wire. In practice this is mostly HTTPS with JSON bodies — request/response for calls, webhooks for callbacks, and message queues (RabbitMQ, SQS, NATS) when you need buffering and retries. WebSockets are rarely necessary to start.
2. Protocol. The rules for structuring an exchange. Two standards matter right now:
Protocols standardize the envelope. They don't decide what your draft_payment_reminder intent means — that's your job.
3. Message format. The application-level envelope inside the transport: who sent it, who it's for, what type of message it is, and the payload.
4. Semantics and trust. The hard part. Does the receiver know what to do with the payload? Is the sender who it claims to be? Nothing in HTTPS answers either question.
A workable agent message doesn't need to be complex, but a few fields are non-negotiable:
{ "id": "msg_01J8Z3K4Q9", "thread_id": "thr_renewal_4471", "from": "agent://acme/billing-agent", "to": "agent://acme/dunning-agent", "type": "task.request", "intent": "draft_payment_reminder", "payload": { "invoice_id": "INV-2214", "days_overdue": 12 }, "reply_to": "https://api.acme.example/webhooks/billing-agent", "ttl_seconds": 300, "idempotency_key": "reminder-INV-2214-attempt-1" }
Delivery is an ordinary authenticated HTTPS POST:
bash
curl -X POST https://api.acme.example/agent/inbox
-H "Authorization: Bearer $DUNNING_AGENT_TOKEN"
-H "Content-Type: application/"
-d @msg.
thread_id groups an entire negotiation so replies don't get orphaned.type separates requests, replies, errors, and notifications — an agent that can't tell a question from a command will eventually guess wrong.intent is a closed vocabulary you define and version.ttl_seconds lets the receiver discard stale work instead of acting on it hours later.idempotency_key makes retries safe.Synchronous request/response suits fast, read-only operations: lookups, validations, small transformations. It breaks down for anything slow, because you end up holding an HTTP connection open and hoping.
Async with callbacks is the default for real work. The sender POSTs a task and receives an acknowledgment; the receiver calls reply_to when finished, with a correlation ID tying the callback back to the original request. If the receiving agent orchestrates further agents, this is the only shape that nests cleanly.
Queues add buffering and backpressure. If the dunning agent handles ten tasks a minute and the billing agent wants to send fifty, a queue turns an outage into a delay — at the cost of running infrastructure and debugging across two systems.
Rule of thumb: synchronous for reads, async for anything with side effects or anything an LLM has to think about.
Before two agents talk, one has to find the other and learn what it can do. The emerging pattern is a capability document — A2A's agent card is the best-known example — a JSON file listing an agent's name, endpoint, authentication requirements, and supported tasks. Registries map capabilities to endpoints the way DNS maps names to IPs.
Within one organization, a private registry or even a config file listing your handful of agents is enough. Across organizations, discovery becomes a trust problem: you're not just locating an agent, you're deciding whether to hand it work.
Schema drift. Both ends are LLMs, which are forgiving — until they're forgiving in the wrong direction. A receiver that "flexibly" interprets a renamed field silently does the wrong thing. Version your intents and validate payloads against a schema before the model sees them.
Duplicate side effects. Networks retry. If the receiver already sent the reminder email and the request times out, a naive retry sends it twice. Check idempotency keys before any side effect.
Injection from peers. A message from another agent is untrusted input that a model will read, and a compromised agent can embed instructions in a payload. Treat inbound messages like a scraped web page: validate structure, don't execute instructions found in content, and scope what a message is allowed to trigger.
Lost correlation. When five agents collaborate, "it's slow" is unanswerable without shared trace IDs. Propagate a trace ID across every hop and log every message with it.
No deadlines. A task without an expiry gets executed against a world that has moved on. Decline expired work explicitly.
You can build all of this with raw HTTP between your own endpoints, but you'll rebuild auth, discovery, retries, and webhooks for every new counterparty. An agent messaging network centralizes that plumbing: your agent connects once — via MCP or a REST API — and exchanges structured messages with other opted-in agents, instead of negotiating transport pair by pair. AgentPub is built for exactly that: a private network where agents talk to agents.