How Do AI Agents Communicate With Each Other?
AI agents communicate through structured messages, async queues, and coordination protocols. Learn the key patterns to build multi-agent systems.
// 5 min read · ● updated 2026-06
// before reading
AI agents communicate through a stack of three layers: a message format (typically JSON with a strict schema), a transmission channel (in-memory calls, message queues, or a shared blackboard), and a coordination protocol (handoff, bidding, voting, or tool-based signals). Getting these three layers right is what separates a toy demo from a production multi-agent system that can recover from failures, scale horizontally, and produce reliable results.
Pro Tip: If you're new to agents, don't build communication from scratch. Frameworks like LangGraph, CrewAI, and AutoGen ship these patterns built-in. Learn them first, customize later.
What is it
Agent-to-agent communication is the structured exchange of data between autonomous entities powered by LLMs. Each agent typically has:
- A distinct role (researcher, reviewer, writer, validator)
- Different tools (web access, database queries, APIs)
- Separate memory (conversation history, task context)
- A unique system prompt (behavioral instructions)
This isn't two chatbots chatting. It's a contract-based exchange where sender and receiver agree on schema, purpose, and flow beforehand.
Note: Don't confuse "agent" with "tool". An agent makes autonomous decisions using an LLM. A tool is a function an agent calls. Agent-to-agent communication involves decisions, not just execution.
Mental model
Picture a dev team shipping a complex feature. Not everyone does everything: one person handles the backend, another the frontend, another reviews PRs. They coordinate through Jira tickets (structured messages), PR comments (reviews), and Slack (quick pings). AI agents work the same way — passing structured payloads, partial results, and completion signals.
The four fundamental communication patterns:
| Pattern | Description | Best for |
|---|---|---|
| Orchestrator-worker | A central agent assigns tasks and collects results | Linear flows with supervision |
| Peer-to-peer | Autonomous agents send direct messages | Decentralized systems |
| Blackboard | All agents read/write to a shared space | Parallel processing |
| Debate | Multiple agents discuss until consensus | Quality verification, review |
How it's used
Building agent communication means defining three layers. Here's a step-by-step breakdown.
1. Define the message format
JSON with a strict schema is the industry standard. Every message needs: sender, recipient, type, payload, and metadata.
{
"from": "agent-researcher",
"to": "agent-writer",
"type": "task_result",
"payload": {
"query": "Agent architectures in 2026",
"findings": "...",
"sources": ["url1", "url2"],
"confidence": 0.92
},
"metadata": {
"timestamp": "2026-06-01T10:00:00Z",
"trace_id": "abc-123",
"priority": "high",
"retry_count": 0
}
}Pro Tip: Use Pydantic (Python) or Zod (TypeScript) to define and validate your message schemas. If agents can mutate the format on the fly, you'll get bugs from subtle field mismatches that are a nightmare to debug.
2. Choose the transmission channel
Three main strategies, ordered from simplest to most robust:
In-memory channel (synchronous)
The orchestrator calls functions directly and awaits results. Great for prototyping.
# Conceptual example with LangGraph
researcher = create_agent(tools=[search_tool])
writer = create_agent(tools=[write_tool])
research_result = researcher.run("find data on X")
final_article = writer.run(f"write article based on: {research_result}")Pro: Simple, fast to implement. Con: If one agent fails, the whole flow dies. Doesn't scale.
Message queue (asynchronous)
Each agent listens to a queue and processes messages as they arrive. The production standard.
1. Orchestrator publishes task to queue "research.tasks"
2. Agent-researcher consumes, executes search
3. Agent-researcher publishes result to "review.tasks"
4. Agent-reviewer consumes, validates quality
5. Agent-reviewer publishes to "writing.tasks"
6. Agent-writer consumes and writes the final document
7. Agent-writer publishes to "results"
8. Orchestrator receives result and replies to user# Pseudocode with Redis/SQS
from agent_queue import QueueAgent
class ResearchAgent(QueueAgent):
def process(self, message):
findings = self.search(message["query"])
self.publish("review.tasks", {
"query": message["query"],
"findings": findings,
"from": "research"
})Warning: Async queues don't guarantee processing order. If your flow needs strict sequential execution, use a shared state (DAG state) or an orchestrator that tracks progress. LangGraph handles this with its state graph.
Shared blackboard
All agents read from and write to a common store. Ideal for parallel work.
# Pseudocode with a vector database as a blackboard
blackboard = VectorStore(collection="project-alpha")
class ResearchAgent:
def run(self, task):
results = self.search(task)
blackboard.add("research_results", results)
blackboard.set_flag(f"task_{task['id']}", "research_done")
class WriterAgent:
def run(self):
if blackboard.get_flag("research_done"):
data = blackboard.get("research_results")
article = self.write(data)
blackboard.add("drafts", article)3. Define the coordination protocol
The protocol determines how communication starts, flows, and ends:
| Protocol | How it works | Best for |
|---|---|---|
| Handoff | An agent explicitly passes control to the next | Known sequential flows |
| Bidding | The orchestrator broadcasts a task; agents bid if they can do it | Systems with heterogeneous agents |
| Voting | Multiple agents generate responses; a meta-agent or majority picks the best | High-accuracy tasks |
| Tool-based | An agent writes to a shared resource; another detects it and continues | Legacy system integration |
Pro Tip: Voting is especially useful for reducing hallucinations. Send the same query to 3 agents with different system prompts, then use a 4th agent to synthesize the most consistent answer. This is called "agent ensembling," and it's one of the most practical reliability patterns available today.
When to use it / when not to
Use it when:
- The task requires multi-domain skills (e.g., web research + writing + translation)
- You need specialization: each agent has distinct roles, tools, and context
- You want to scale horizontally: add more agents of the same type to handle more load
- The problem is decomposable into independent steps that can run in parallel
- You need resilience: if one agent fails, another can pick up from the last known state
Don't use it when:
- A single agent handles the task with a well-crafted prompt (always start simple)
- The coordination overhead outweighs the specialization benefit — measure before scaling
- Latency is critical: each agent hop adds LLM inference time + transmission overhead
- You don't have a clear message schema or defined protocol (you'll build a fragile system)
- The number of agents is very small and communication adds artificial complexity
Pro Tip: The golden rule: start with one agent, add more only when you have evidence that a single agent can't solve the problem. Agent communication is a solution to complexity, not a goal in itself.
// related