Learn how AI agents exchange information and coordinate actions through structured messages, communication patterns like pub-sub and request-response, and protocols for task delegation and consensus building.

This article is part of the free-to-read AI Agent Handbook
Communication Between Agents
In the previous chapter, you saw how multiple agents can work together by specializing in different tasks. But we glossed over a critical detail: how do agents actually talk to each other? When the guest agent finishes compiling dietary restrictions, how does it pass that information to the menu agent? When the research agent finds important data, how does it tell the writing agent?
Human teams communicate through language, gestures, emails, and meetings. AI agents need their own communication mechanisms. In this chapter, we'll explore how agents exchange information, coordinate their actions, and stay synchronized while working toward shared goals.
The Communication Challenge
Let's start with a concrete problem. Imagine you have two agents:
- Agent A (Research): Finds the current price of Bitcoin
- Agent B (Analysis): Determines if now is a good time to buy
Agent B needs the information Agent A discovers. But how does Agent A send that information? And how does Agent B know it's receiving price data rather than, say, historical trends or market sentiment?
Here's what makes agent communication tricky:
Different Contexts: Each agent has its own conversation history, system prompt, and state. When Agent A says "the price is $45,000," Agent B needs enough context to understand what that means.
Timing: Agent B might need to wait for Agent A to finish its research. How does it know when Agent A is done? What if Agent A encounters an error?
Format: Should Agent A send a simple number, a structured JSON object, or a natural language description? The format affects how easily Agent B can use the information.
Reliability: What if the message gets lost or corrupted? What if Agent A sends information that Agent B doesn't understand?
Let's see these challenges in action with a simple example:
Research Agent found:
```json
{
"topic": "Electric Vehicle Sentiment Analysis",
"findings": {
"overall_sentiment": "Mixed but trending positive",
"positive_factors": [
"Environmental benefits and reduced emissions",
"Lower operating costs compared to gasoline vehicles",
"Improved technology and longer range capabilities",
"Government incentives and tax credits in many regions",
"Growing charging infrastructure",
"Performance advantages (instant torque, quiet operation)"
],
"concerns": [
"Higher upfront purchase costs",
"Charging time compared to gasoline refueling",
"Range anxiety for long-distance travel",
"Charging infrastructure gaps in rural areas",
"Battery degradation over time",
"Supply chain and raw material sourcing questions",
"Grid capacity concerns with mass adoption"
],
"market_trends": [
"Sales growth continues globally despite economic headwinds",
"Traditional automakers rapidly expanding EV lineups",
"China leading in production and adoption",
"Europe showing strong policy support",
"U.S. market growing but still relatively smaller percentage of total sales"
],
"demographic_variations": [
"Younger consumers generally more enthusiastic",
"Urban residents more positive than rural",
"Early adopters satisfied, mainstream buyers more cautious",
"Business/fleet operators increasingly interested in TCO benefits"
]
},
"confidence": "High - based on consistent market data, sales trends, and consumer surveys from 2023-2024"
}
```
Analysis Agent recommends: # Electric Vehicle Sentiment Analysis: Strategic Recommendations ## Executive Summary The research reveals a market at an inflection point—sentiment is positive and growing, but significant barriers remain for mainstream adoption. Success requires targeted strategies addressing specific customer segments and pain points. --- ## Priority Recommendations ### 1. **Address the Cost-Value Perception Gap** **Actions:** - **Educate on Total Cost of Ownership (TCO)**: Create calculators and comparison tools showing 5-year costs including fuel savings, maintenance, and incentives - **Flexible financing options**: Partner with financial institutions for EV-specific loans with lower rates - **Trade-in programs**: Offer premium valuations for gas vehicles to offset upfront cost concerns - **Target fleet operators first**: Their TCO focus makes them ideal early mainstream adopters—build case studies for consumer marketing **Why**: Higher upfront costs are the #1 barrier, but the math favors EVs over time. Make this transparent. --- ### 2. **Segment Your Market Strategy** **Urban vs. Rural Approach:** **Urban Markets (Priority 1):** - Emphasize convenience of home/work charging - Highlight performance and tech features - Focus on environmental benefits - Leverage existing infrastructure density **Rural Markets (Secondary Phase):** - Partner with utilities on charging infrastructure - Emphasize range improvements prominently - Consider plug-in hybrids as bridge products - Use local dealerships as charging hubs **Why**: Demographics show clear divides—allocate resources where adoption likelihood is highest first. --- ### 3. **Eliminate Range Anxiety Through Psychology & Infrastructure** **Tactical Solutions:** - **Real-world range guarantees**: Offer buy-back/exchange if customers experience genuine range limitations in first year - **Free charging packages**: Include 2-3 years of public charging credits with purchase - **Trip planning integration**: Built-in navigation showing charging stops (make it foolproof) - **Strategic infrastructure partnerships**: Work with governments/businesses to fill rural gaps on major routes **Communication Strategy:** - Lead marketing with actual range numbers in varied conditions - Show real customer testimonials about long-distance travel - Emphasize that 95% of daily driving is within easy range **Why**: Range anxiety is psychological more than practical
This works, but notice the limitations. The analysis agent receives raw text from the research agent. It has to parse that text and hope it contains the information it needs. There's no guarantee the format will be consistent, no way to verify the message was understood correctly, and no mechanism for the analysis agent to ask follow-up questions.
We can do better.
Message Formats: Speaking a Common Language
The first step to better communication is establishing a shared format. Just as humans might agree to communicate via email with specific subject lines and structure, agents benefit from standardized message formats.
Natural Language Messages
The simplest approach is natural language. Agent A sends a message like "I found that Bitcoin is currently trading at $45,000 with high volatility." Agent B reads this and responds accordingly.
Advantages:
- Flexible and expressive
- Easy to understand when debugging
- Works well with language models' strengths
Disadvantages:
- Ambiguous (what does "high volatility" mean exactly?)
- Hard to parse programmatically
- Prone to misinterpretation
Natural language works well for high-level coordination where precision isn't critical. For example, a coordinator agent might tell worker agents: "Focus on the Q4 data" or "Prioritize accuracy over speed."
Structured Data Messages
For precise information exchange, structured formats like JSON work better:
Now Agent B knows exactly what it's receiving. The price is a number, not a string. The volatility is quantified. The confidence score indicates how reliable this information is. The timestamp shows when the data was collected.
Let's rebuild our example with structured communication:
=== Structured Agent Communication ===
Research Agent sent:
{
"from": "research_agent",
"to": "analysis_agent",
"type": "research_complete",
"timestamp": "2025-12-07T12:03:02.665175",
"data": {
"topic": "Benefits of renewable energy",
"findings": [
"Environmental benefits: Renewable energy sources produce little to no greenhouse gas emissions or air pollutants during operation, helping combat climate change and reduce air pollution-related health issues",
"Energy independence: Reduces reliance on imported fossil fuels and enhances national energy security by utilizing domestic resources like sun, wind, and water",
"Economic advantages: Creates jobs in manufacturing, installation, and maintenance sectors; solar and wind are now cost-competitive with or cheaper than fossil fuels in many regions",
"Sustainability: Renewable sources are inexhaustible on human timescales, unlike finite fossil fuel reserves",
"Price stability: Operating costs are more predictable as fuel costs are eliminated; insulates consumers from volatile fossil fuel price fluctuations",
"Health benefits: Reduces respiratory diseases, cardiovascular problems, and premature deaths associated with fossil fuel pollution",
"Grid resilience: Distributed renewable energy systems can improve grid reliability and reduce transmission losses",
"Water conservation: Most renewable technologies use significantly less water than conventional thermal power plants"
],
"sources": [
"International Energy Agency (IEA) reports on renewable energy",
"U.S. Department of Energy and Environmental Protection Agency studies",
"International Renewable Energy Agency (IRENA) publications",
"Academic research from environmental science journals",
"National Renewable Energy Laboratory (NREL) data",
"World Health Organization studies on air quality and health"
],
"confidence": 0.95
}
}
Analysis Agent sent:
{
"from": "analysis_agent",
"to": "research_agent",
"type": "analysis_complete",
"timestamp": "2025-12-07T12:03:10.502700",
"data": {
"recommendation": "Accelerate investment and policy support for renewable energy transition across all sectors, prioritizing solar and wind deployment while developing grid infrastructure and energy storage solutions to maximize environmental, economic, and health benefits",
"reasoning": "The research demonstrates overwhelming evidence across multiple dimensions: (1) Environmental - significant reduction in greenhouse gases and air pollution; (2) Economic - cost competitiveness achieved, job creation potential, and price stability advantages; (3) Health - measurable reduction in pollution-related diseases and mortality; (4) Strategic - enhanced energy security and independence from volatile fossil fuel markets; (5) Sustainability - inexhaustible resources ensuring long-term viability. The high confidence score (0.95) and credible sources (IEA, IRENA, NREL, WHO) validate these findings. The convergence of economic viability with environmental necessity creates a rare policy alignment where financial and ecological interests coincide, making this an optimal time for aggressive renewable energy expansion",
"confidence": 0.92
}
}
This structured approach gives us several benefits:
Type Safety: The message_type field lets agents verify they're receiving the expected kind of message.
Traceability: Timestamps and sender/recipient fields create an audit trail of communication.
Error Handling: Agents can send error messages in the same format, making it easy to handle failures.
Extensibility: You can add new message types without breaking existing communication patterns.
Communication Patterns
Now that we have a message format, let's explore different ways agents can communicate.
Request-Response
The simplest pattern: Agent A sends a request, Agent B sends a response.
This is synchronous. Agent A waits for Agent B's response before continuing. It's straightforward but can be inefficient if Agent B takes a long time.
Fire-and-Forget
Agent A sends a message but doesn't wait for a response. It continues with other work.
This is asynchronous and efficient, but Agent A has no way to know if the message was received or processed successfully.
Publish-Subscribe
Multiple agents can subscribe to specific types of messages. When Agent A publishes a message, all subscribed agents receive it.
This pattern works well for broadcasting information to multiple interested parties without Agent A needing to know who they are.
Here's a simple implementation:
trading_agent subscribed to 'market_data' analysis_agent subscribed to 'market_data' reporting_agent subscribed to 'market_data' logging_agent subscribed to 'user_actions' analytics_agent subscribed to 'user_actions' Publishing to 'market_data' (3 subscribers) Notified: trading_agent, analysis_agent, reporting_agent Publishing to 'user_actions' (2 subscribers) Notified: logging_agent, analytics_agent
Conversation Threads
For complex coordination, agents might need back-and-forth conversations:
This requires maintaining conversation context. Each message needs to reference the thread it belongs to:
=== Conversation Thread === Conversation thread meeting_planning_001 Participants: coordinator_agent, calendar_agent coordinator_agent: I need to schedule a team meeting for next week. calendar_agent: I can see Tuesday 2pm or Thursday 3pm are available. Which works better? coordinator_agent: Tuesday 2pm works. Please book it. calendar_agent: Meeting scheduled for Tuesday at 2pm. I've sent invites to all team members.
Coordination Protocols
Message formats and patterns are building blocks. Coordination protocols define the rules for how agents work together on specific types of tasks.
Task Delegation Protocol
When one agent needs another agent to do work:
- Request: Coordinator sends a task with clear requirements
- Acknowledgment: Worker confirms it received the task
- Progress Updates: Worker sends periodic status updates
- Completion: Worker sends results or error message
- Confirmation: Coordinator acknowledges receipt
=== Task Delegation Protocol ===
1. Task Requested:
{
"from": "coordinator",
"to": "research_agent",
"type": "task_request",
"timestamp": "2025-12-07T12:03:10.535184",
"data": {
"task_id": "research_001",
"coordinator": "coordinator",
"worker": "research_agent",
"description": "Research the top 3 cloud providers and compare pricing",
"status": "requested",
"created_at": "2025-12-07T12:03:10.535176",
"updates": []
}
}
2. Task Acknowledged:
{
"from": "research_agent",
"to": "coordinator",
"type": "task_acknowledged",
"timestamp": "2025-12-07T12:03:10.535241",
"data": {
"task_id": "research_001"
}
}
3. Progress Update:
{
"from": "research_agent",
"to": "coordinator",
"type": "task_progress",
"timestamp": "2025-12-07T12:03:10.535274",
"data": {
"task_id": "research_001",
"progress": "Completed research on AWS, starting Azure"
}
}
4. Task Complete:
{
"from": "research_agent",
"to": "coordinator",
"type": "task_complete",
"timestamp": "2025-12-07T12:03:10.535312",
"data": {
"task_id": "research_001",
"results": {
"providers": [
"AWS",
"Azure",
"Google Cloud"
],
"comparison": "Detailed pricing comparison...",
"recommendation": "AWS offers best value for your use case"
}
}
}
Final Status: completed
Updates: 2 progress updates
This protocol ensures both agents stay synchronized. The coordinator knows the task is being worked on, can track progress, and receives results in a predictable format. The worker has a clear structure for communicating its status.
Consensus Protocol
When multiple agents need to agree on something:
- Proposal: One agent proposes a decision
- Voting: All agents vote (agree, disagree, abstain)
- Tally: Votes are counted according to rules (majority, unanimous, weighted)
- Decision: Result is announced to all agents
agent_a proposed: Upgrade to the new model version (higher cost but better performance) Proposal ID: upgrade_001 Waiting for votes from: agent_a, agent_b, agent_c, agent_d agent_a voted: agree agent_b voted: agree agent_c voted: agree agent_d voted: disagree Proposal upgrade_001: ACCEPTED Votes: 3/4 agreed (75%) Threshold: 75% Final decision: accepted
Handling Communication Failures
Communication between agents isn't always perfect. Networks fail, messages get lost, agents crash. Robust multi-agent systems need to handle these failures gracefully.
Timeouts
If Agent A sends a request to Agent B and doesn't get a response within a reasonable time, it should timeout and either retry or report an error:
Retries
For transient failures, retrying can help:
Acknowledgments
For critical messages, require acknowledgments:
Real-World Communication: The A2A Protocol
Earlier we discussed the Agent-to-Agent (A2A) Protocol as a framework for multi-agent systems. Now let's look specifically at how A2A handles communication.
A2A defines standard message formats and communication patterns that work across different platforms. When agents use A2A, they can communicate even if one is built with Claude, another with GPT-5, and a third with Gemini.
Key A2A Communication Features:
Agent Discovery: Agents can find other agents by querying a registry. "Are there any research agents available?" returns a list of agents with their capabilities.
Capability Negotiation: Before communicating, agents can check if they speak compatible "languages." Agent A can ask Agent B: "Do you accept JSON input?" or "Can you return image data?"
Standardized Message Envelope: All A2A messages include metadata (sender, recipient, timestamp, message type) in a consistent format, similar to our AgentMessage class but with additional fields for authentication and routing.
Task Lifecycle Management: A2A includes built-in protocols for task delegation, progress tracking, and completion, similar to our TaskDelegationProtocol but standardized across all A2A-compatible agents.
Error Handling: A2A defines standard error codes and formats, so agents can understand what went wrong even across different implementations.
While we won't implement the full A2A protocol here (it's complex and still evolving), the patterns we've explored in this chapter align with A2A's design principles. When you build multi-agent systems, following similar patterns will make your agents more interoperable and maintainable.
Practical Considerations
As you design communication between your agents, keep these principles in mind:
Keep Messages Small: Large messages slow down communication and increase the chance of errors. If you need to share a big dataset, send a reference (like a file path or database query) rather than the data itself.
Be Explicit: Don't assume the receiving agent has context. Include enough information in each message for it to be understood independently.
Version Your Protocols: As your system evolves, message formats might change. Include version numbers so agents can handle different formats gracefully.
Log Everything: Communication logs are invaluable for debugging. When something goes wrong, being able to trace the message flow helps you find the problem quickly.
Design for Failure: Assume messages will get lost, delayed, or corrupted. Build in timeouts, retries, and error handling from the start.
Test Communication Separately: Before building complex multi-agent workflows, test that your agents can reliably exchange simple messages. Get the communication layer working first, then add sophisticated behaviors.
Looking Ahead
You now understand how agents communicate: through structured messages, following specific patterns (request-response, pub-sub, conversations), using coordination protocols (task delegation, consensus), and handling failures gracefully.
In the next chapter, we'll explore the benefits and challenges of multi-agent systems in more depth. You'll learn when the added complexity of multiple agents is worth it, what problems can arise, and how to design multi-agent systems that are robust, efficient, and maintainable.
The key insight from this chapter is that communication is the foundation of collaboration. Just as human teams need clear communication channels and protocols, AI agents need well-designed message formats and coordination mechanisms. Get the communication right, and your agents can accomplish remarkable things together.
Glossary
Acknowledgment: A message sent by a recipient to confirm that it received and understood a previous message, used to ensure reliable communication.
Asynchronous Communication: A pattern where the sender doesn't wait for a response and continues with other work, useful for fire-and-forget messages and parallel processing.
Consensus Protocol: A set of rules for how multiple agents reach agreement on decisions through proposals, voting, and tallying results according to defined thresholds.
Conversation Thread: A sequence of related messages between agents, maintained with a thread ID and message history to preserve context across multiple exchanges.
Message Broker: A component that manages publish-subscribe communication, routing messages from publishers to all subscribed agents based on topics.
Message Envelope: The wrapper around message content that includes metadata like sender, recipient, timestamp, and message type, enabling proper routing and handling.
Publish-Subscribe: A communication pattern where agents subscribe to topics of interest and receive all messages published to those topics, enabling one-to-many communication.
Request-Response: A synchronous communication pattern where one agent sends a request and waits for another agent to send back a response before continuing.
Structured Data: Information formatted in a standardized way (like JSON) with defined fields and types, making it easier for agents to parse and use reliably.
Task Delegation Protocol: A coordination protocol that defines how one agent requests work from another, including acknowledgment, progress updates, completion, and error handling.
Timeout: A mechanism that limits how long an agent waits for a response before concluding the message was lost or the recipient is unavailable.
Quiz
Ready to test your understanding? Take this quick quiz to reinforce what you've learned about agent communication patterns and protocols.
Reference

About the author: Michael Brenndoerfer
All opinions expressed here are my own and do not reflect the views of my employer.
Michael currently works as an Associate Director of Data Science at EQT Partners in Singapore, where he drives AI and data initiatives across private capital investments.
With over a decade of experience spanning private equity, management consulting, and software engineering, he specializes in building and scaling analytics capabilities from the ground up. He has published research in leading AI conferences and holds expertise in machine learning, natural language processing, and value creation through data.
Related Content

Skip-gram Model: Learning Word Embeddings by Predicting Context
A comprehensive guide to the Skip-gram model from Word2Vec, covering architecture, objective function, training data generation, and implementation from scratch.

Benefits and Challenges of Multi-Agent Systems: When Complexity is Worth It
Explore the trade-offs of multi-agent AI systems, from specialization and parallel processing to coordination challenges and complexity management. Learn when to use multiple agents versus a single agent.

Agents Working Together: Multi-Agent Systems, Collaboration Patterns & A2A Protocol
Learn how multiple AI agents collaborate through specialization, parallel processing, and coordination. Explore cooperation patterns including sequential handoff, iterative refinement, and consensus building, plus real frameworks like Google's A2A Protocol.
Stay updated
Get notified when I publish new articles on data and AI, private equity, technology, and more.

Comments