Handoff, shared state, messaging and blackboard
As soon as several AI agents collaborate on a task, how they exchange information becomes the actual architecture decision. Communication patterns such as direct handoff, shared state, structured messaging and the blackboard pattern differ significantly in context consumption, coupling and error proneness, and the wrong choice quickly leads to context loss or conflicting intermediate states.
Table of Contents
- 1. Why communication between agents is its own design problem
- 2. Pattern one: direct handoff with full context
- 3. Pattern two: shared state via a common data source
- 4. Pattern three: message-based communication with structured payloads
- 5. Pattern four: the blackboard pattern for loosely coupled agents
- 6. Sources of error: context loss and conflicting states
- 7. Structured formats instead of free text between agents
- 8. Practical example: a research agent hands off to a writing agent
- 9. The four communication patterns compared
- 10. Summary
- 11. FAQ
1. Why communication between agents is its own design problem
As soon as more than one agent is involved in a task, the question of how information flows between them becomes its own architecture decision. Communication patterns between AI agents determine how much context an agent receives from the previous one, how tightly the agents are coupled to each other, and how easily errors in the handoff can be detected. This decision is underestimated in many projects because it initially looks like a pure implementation detail, but it actually determines the reliability of the entire system.
A poorly chosen communication pattern usually only becomes visible late: an agent makes an assumption it never explicitly communicates, the next agent unknowingly builds on it, and the error only becomes visible once the final result is factually wrong. Deliberately chosen communication patterns between AI agents make such implicit assumptions visible by forcing every handoff to happen in an explicitly structured way, instead of relying on free text and implicit understanding.
At the core, four communication patterns can be distinguished that keep recurring in practice with Claude-based multi agent systems: direct handoff, shared state, structured messaging and the blackboard pattern. Each suits different degrees of coupling and context requirements, and the following sections present each in detail.
2. Pattern one: direct handoff with full context
The direct handoff is the simplest of the communication patterns between AI agents: one agent finishes its work and passes its complete result, sometimes including its reasoning process, directly to the next agent. This pattern works well for short, linear chains with few participants, for example when an analysis agent hands its result straight to exactly one implementation agent.
The advantage of direct handoff lies in its simplicity: there is no additional infrastructure, no shared store and no message queue. The disadvantage shows up once more than two agents are involved, because every additional recipient would need to receive the full context again, which quickly multiplies token volume. Direct handoff is therefore best suited for simple, less branched communication patterns between exactly two to three agents.
{
"communication_pattern": "direct_handoff",
"from_agent": "analysis_agent",
"to_agent": "implementation_agent",
"payload": {
"affected_files": ["src/Model/PriceCalculator.php"],
"finding": "Legacy discount logic bypasses the new TaxRuleRepository",
"recommendation": "Refactor calculateDiscount() to use TaxRuleRepositoryInterface"
},
"handoff_complete": true
}
3. Pattern two: shared state via a common data source
In the shared state pattern, all involved agents write their intermediate results into a common store, for example a file in the repository or a simple key value store, instead of sending results directly to each other. Each agent reads the entries relevant to it from this shared state as needed. This communication pattern decouples agents in time, since no agent has to wait synchronously for another agent's answer before starting its own work.
Another advantage of shared state as a communication pattern between AI agents is traceability: the entire state of the workflow can be inspected at any point in time, without having to reconstruct the history of individual agent calls. The downside is the need to avoid write conflicts, especially when several agents access the same state in parallel. A clear convention about which agent may exclusively write to which section of the state helps here.
# Shared state communication pattern for multi agent systems
# Each agent reads only its relevant slice and writes back its own section
import json
from pathlib import Path
from threading import Lock
STATE_FILE = Path(".claude/shared-state.json")
_lock = Lock()
def read_slice(section: str) -> dict:
with _lock:
state = json.loads(STATE_FILE.read_text()) if STATE_FILE.exists() else {}
return state.get(section, {})
def write_slice(section: str, agent_id: str, data: dict) -> None:
with _lock:
state = json.loads(STATE_FILE.read_text()) if STATE_FILE.exists() else {}
state[section] = {"written_by": agent_id, "data": data}
STATE_FILE.write_text(json.dumps(state, indent=2))
# Analysis agent writes its findings
write_slice("analysis", "analysis_agent", {"affected_files": ["PriceCalculator.php"]})
# Implementation agent reads only the analysis slice, not the full history
analysis = read_slice("analysis")
4. Pattern three: message-based communication with structured payloads
Message-based communication patterns resemble handoff, but introduce an additional layer: agents communicate via a defined queue or message format instead of being directly connected to each other. One agent publishes a message with a fixed schema, and one or more other agents consume this message without sender and recipient having to know each other. This decoupling makes it easier to add new agents to an existing system without having to adjust existing connections.
The decisive advantage of this communication pattern lies in extensibility: a new security review agent can simply be added as an additional consumer of an existing message type, without the original sender needing to know about it or change. The downside is higher infrastructure overhead, especially when messages need to be reliably delivered and error cases like duplicate processing need to be handled.
{
"message_schema": "agent.finding.v1",
"published_by": "code_analysis_agent",
"topic": "review.findings",
"payload": {
"file": "src/Model/Checkout/CartRepository.php",
"line": 142,
"category": "security",
"description": "Unvalidated input passed to raw SQL query"
},
"consumers": ["security_review_agent", "audit_log_agent"]
}
5. Pattern four: the blackboard pattern for loosely coupled agents
The blackboard pattern is the most decoupled variant among the four communication patterns. All agents write to and read from a shared, openly visible board, without a fixed schedule dictating who contributes what and when. An agent observes the board, recognizes that its domain is relevant, and contributes its own input once enough information is available for it. This pattern suits situations where the order of contributions is not fixed in advance.
In practice with Claude-based systems, the blackboard pattern shows up, for example, in exploratory debugging sessions: a log analysis agent contributes observations to the board, a database agent adds information about affected records, and a summary agent only reads the board once enough independent contributions are available. The challenge with this communication pattern lies in defining when the board counts as complete and the final agent should begin its work.
#!/usr/bin/env bash
# Blackboard pattern: independent agents contribute to a shared observation log
set -euo pipefail
BLACKBOARD="workflow/debug-blackboard.jsonl"
contribute() {
local agent_id="$1"
local observation="$2"
printf '{"agent":"%s","observation":"%s","ts":"%s"}\n' \
"$agent_id" "$observation" "$(date -u +%FT%TZ)" >> "$BLACKBOARD"
}
# Independent agents contribute whenever they notice something relevant
contribute "log_agent" "Repeated timeout errors in checkout controller"
contribute "db_agent" "Slow query detected on sales_order_grid table"
# Summary agent waits until enough independent contributions exist
line_count=$(wc -l < "$BLACKBOARD")
if (( line_count >= 2 )); then
echo "[summary_agent] Enough observations collected, synthesizing report"
fi
6. Sources of error: context loss and conflicting states
Regardless of the chosen communication pattern, two recurring error classes occur in multi agent systems. Context loss happens when an agent omits information that would have been relevant to a later agent, because it could not judge its relevance at the time of the handoff. This problem can be reduced by using standardized handoff formats that are as complete as possible, passing along even seemingly irrelevant details in structured form instead of filtering them out prematurely.
Conflicting states, on the other hand, arise when two agents write to the same state simultaneously or in the wrong order and overwrite each other. With shared state and blackboard patterns, this risk can be reduced through clear write permissions per section and through timestamps that enable subsequent conflict resolution. For all four communication patterns, validating the passed data against a fixed schema before an agent processes it further also helps.
7. Structured formats instead of free text between agents
An overarching recommendation for all four communication patterns is to design handoffs between agents as structured data whenever possible instead of as free text. JSON objects with defined fields can be validated programmatically, while free text summaries leave room for interpretation that can lead to slight shifts in meaning with every handoff. These small shifts add up across multiple handoff stages into significant deviations from the original finding.
Structured formats also make it possible to version a schema and document changes to the communication interface in a traceable way, similar to a classic API between software components. Whoever designs communication patterns between AI agents with fixed schemas from the start saves themselves later debugging sessions in which it remains unclear whether an agent actually received a piece of information or merely misunderstood it.
8. Practical example: a research agent hands off to a writing agent
A concrete example from technical documentation illustrates the choice of the right pattern: a research agent searches a codebase for all public methods of a new API class and collects signatures, return values and existing PHPDoc comments. A writing agent is supposed to build a complete API documentation from this. A direct handoff with a structured payload suits this better than a blackboard pattern, because the relationship is clearly linear and no further agents are involved.
The handoff happens as structured JSON with a list of method objects, each with name, parameters, return type and existing documentation. The writing agent thereby receives all necessary information in a consistent format and does not have to search the codebase again itself. This simple communication pattern shows that not every agent communication needs complex infrastructure, as long as the structure of the handoff is clearly defined.
{
"communication_pattern": "direct_handoff",
"from_agent": "research_agent",
"to_agent": "writing_agent",
"payload": {
"methods": [
{
"name": "calculateShippingCost",
"parameters": ["Address $destination", "float $weight"],
"return_type": "Money",
"existing_phpdoc": "Calculates shipping cost for a given destination and weight."
},
{
"name": "applyDiscount",
"parameters": ["Money $price", "DiscountRuleInterface $rule"],
"return_type": "Money",
"existing_phpdoc": null
}
]
}
}
9. The four communication patterns compared
The following overview summarizes the key properties of the four communication patterns presented and helps with choosing one for a concrete project.
| Pattern | Coupling | Best suited for |
|---|---|---|
| Direct handoff | Tight, point to point | Short, linear chains with two to three agents |
| Shared state | Loose, decoupled in time | Longer workflows with several stages |
| Messaging | Loose, extensible | Systems with a growing number of agents |
| Blackboard | Very loose | Exploratory tasks with no fixed order |
None of the four communication patterns is inherently superior, each solves a different coupling problem. The choice should be based on the actual structure of the workflow: clear, short chains benefit from simple handoff, while growing, unpredictable systems benefit from loose coupling through shared state, messaging or blackboard.
Mironsoft
Architecture and design of multi agent systems with Claude
Want clear communication paths for your agent landscape?
We design suitable communication patterns for your multi agent system, from simple handoffs to shared state and blackboard architectures, with clear schemas and traceable data flow.
Architecture consulting
Choosing the right communication pattern for your workflow
Schema design
Structured handoff formats instead of free text between agents
Error analysis
Systematically tracking down context loss and conflicting states
10. Summary
Communication patterns between AI agents largely determine the reliability of a multi agent system. Direct handoff suits short, clear chains. Shared state decouples agents in time and makes the overall state inspectable. Message-based communication makes it easier to add new agents. The blackboard pattern fits exploratory tasks with no fixed order. None of these patterns is universally superior, the right choice depends on the structure of the respective workflow.
Regardless of the chosen pattern, consistently using structured, validatable data formats instead of free text considerably reduces the risk of context loss and conflicting states. Whoever deliberately designs communication patterns from the start, instead of letting them emerge implicitly, builds multi agent systems that remain traceable and maintainable even after several expansion stages.
Communication patterns between AI agents, the key takeaways
Handoff
Simple and direct, suited for short chains with few participants.
Shared state
Decouples in time, makes the state inspectable at any point.
Messaging and blackboard
Loose coupling for growing or exploratory multi agent systems.
Structured formats
JSON instead of free text reduces context loss and meaning drift.