The Core Idea: Agents on a team cooperate by passing messages and by sharing a common context. A clear message format, a shared blackboard and defined roles let agents solve problems together instead of repeating or contradicting each other.
- Beginner: Agent-to-Agent Communication
When several agents work together, they need a way to talk. In most systems an agent's output simply becomes another agent's input. There are two common ways:
| Style | How it works | Good for |
|---|---|---|
| Direct messages | One agent sends a message to a named agent | Clear handoffs |
| Shared context (blackboard) | Agents read and write a common workspace | Many agents using the same facts |
| Broadcast | One message goes to everyone | Announcements, status updates |
Remember: Agents do not understand each other by magic. Everything they know about the others is what is written in messages and shared context.
- Beginner: Message Passing
A good message is structured so the receiver knows what to do with it:
| Field | Example from the code |
|---|---|
| from | researcher |
| to | writer |
| kind | notes, draft, revise, approved |
| content | The text or data being passed |
In the code: The reviewer rejects the first draft with a revise message. The writer then sends a second draft, and the reviewer approves. Six messages in total.
- Medium: Shared Context
Sending big documents in every message is wasteful. Instead, agents write large or shared information to a blackboard (a shared store) and pass only a short pointer in messages.
| On the blackboard | In a message |
|---|---|
| The 3 collected facts | 3 facts saved on the blackboard |
| The full draft | The short draft text for the reviewer |
Benefits: Less duplicated text, a single source of truth, and an easy record of the work.
Risks: Two agents can overwrite each other, and wrong information on the blackboard spreads to everyone. Use version checks and validate what is written.
- Medium: Collaborative Problem Solving
Teams solve problems best when roles are clear and each agent checks another agent's work:
| Role | Job | Hands over |
|---|---|---|
| Researcher | Collects facts and sources | Notes to the writer |
| Writer | Turns notes into a draft | Draft to the reviewer |
| Reviewer | Checks quality and accuracy | Approval or a revision request |
Why a reviewer helps: A separate agent with a different instruction is more likely to catch mistakes than the writer re-reading its own work. Give the reviewer concrete criteria, not just check it.
- Advanced: Making Communication Reliable
| Problem | Fix |
|---|---|
| Vague messages | Use a fixed format with a kind field |
| Endless back-and-forth | Limit rounds, as the reviewer loop did |
| Lost messages | Keep a log and acknowledge important ones |
| Wrong handoff | Validate each message before it is used |
| Too much chatter | Send only what the receiver needs |
| Conflicting facts | One source of truth, with version checks |
Reminder: Every message costs tokens and adds a possible error. Agents should communicate as little as possible, but as clearly as necessary.
- Visual Explanation: Six Messages and a Shared Blackboard
The figure follows the six messages exchanged in the code, then shows how messages and the shared blackboard divide the work.
Click to see why a separate reviewer helpsCompare ▼
Part 1 groups the six messages into research, write and review, and revise and approve. Part 2 compares messages with the blackboard. Open the bar for the value of a separate reviewer.
- Python Implementation: Message Passing and a Shared Blackboard
This script runs three agents (researcher, writer, reviewer) that communicate only by messages and a shared blackboard. The reviewer rejects the first draft, the writer revises it, and the reviewer approves it. A log shows every message.
from collections import deque blackboard = {} # shared context every agent can readmessages = deque() # the message buslog = [] def send(sender, to, kind, content): messages.append({"from": sender, "to": to, "kind": kind, "content": content}) log.append(sender + " -> " + to + " [" + kind + "]: " + str(content)) def researcher(msg): if msg["kind"] == "task": blackboard["facts"] = ["agents use tools", "agents loop", "agents need limits"] send("researcher", "writer", "notes", "3 facts saved on the blackboard") def writer(msg): if msg["kind"] == "notes": blackboard["draft"] = "Report using " + str(len(blackboard["facts"])) + " facts" send("writer", "reviewer", "draft", blackboard["draft"]) elif msg["kind"] == "revise": blackboard["draft"] += " plus a summary" send("writer", "reviewer", "draft", blackboard["draft"]) def reviewer(msg): if msg["kind"] == "draft": if "summary" in msg["content"]: send("reviewer", "user", "approved", msg["content"]) else: send("reviewer", "writer", "revise", "please add a summary") AGENTS = {"researcher": researcher, "writer": writer, "reviewer": reviewer} send("user", "researcher", "task", "Write a short report about agents")while messages: message = messages.popleft() if message["to"] in AGENTS: AGENTS[message["to"]](message) print("\n".join(log))print("Messages exchanged:", len(log), "| blackboard keys:", sorted(blackboard))The log shows the entire collaboration. Facts live on the blackboard, while the messages stay short. The review loop ends after one revision. In real systems each agent would be a model call with its own instructions, but the communication pattern is the same.
Knowledge Check
Key Points
The Big Picture
Clear roles + structured messages + a shared blackboard + a reviewer + a round limit
Good communication design is what separates a team of agents from a crowd of agents.
Up Next: Teams need a shape. In Multi-Agent Architectures you will compare supervisor, hierarchical, sequential, parallel and peer-to-peer designs.