Skip to content

01. Agent Communication Overview

Category: Agent Communication Module: AI Agents Prerequisites: AI Agent Fundamentals, Agent Memory Difficulty: Intermediate

Note: Modern AI systems rarely consist of a single intelligent agent. Instead, multiple specialized agents collaborate to solve complex problems by exchanging tasks, information, decisions, and results. Agent Communication defines how AI agents interact with each other, external tools, APIs, humans, and enterprise systems in a reliable, scalable, and production-ready manner.


Overview

Imagine building an AI Software Engineering Assistant.

Instead of one large agent doing everything, you create specialized agents.

Software Engineer


AI Supervisor


Planner Agent


Code Agent


Testing Agent


Documentation Agent

Each agent has a specific responsibility.

However, specialization alone is not enough.

The agents must communicate efficiently.

For example,

Planner Agent


Generate implementation plan


Code Agent


Write source code


Testing Agent


Execute tests


Documentation Agent


Generate README

Without communication, every agent works independently and cannot collaborate.

Agent Communication enables multiple AI agents to exchange information, coordinate tasks, and achieve a common objective.


Why Agent Communication Matters

Without Communication

Agent A

Agent B

Agent C

(No interaction)

Problems

  • Duplicate work
  • No coordination
  • Inconsistent decisions
  • Workflow failures
  • Poor scalability

With Communication

             Supervisor Agent
     ┌──────────────┼──────────────┐
     ▼              ▼              ▼
 Planner        Developer       Tester
     │              │              │
     └──────────────┼──────────────┘
             Shared Information

Benefits

  • Better collaboration
  • Parallel execution
  • Task delegation
  • Faster workflows
  • Scalable AI systems

High-Level Architecture

                        User
                  Supervisor Agent
      ┌───────────────────┼────────────────────┐
      ▼                   ▼                    ▼
 Planner Agent      Coding Agent        Testing Agent
      │                   │                    │
      └──────────────┬────┴──────────────┬─────┘
                     ▼                   ▼
              Communication Layer
      ┌──────────────┼───────────────┐
      ▼              ▼               ▼
 Message Bus     Event Queue     Shared Memory
              External Services

The Communication Layer enables agents to exchange information without requiring direct knowledge of each other.


Communication Lifecycle

Agent communication generally follows a structured workflow.

Create Message


Send Message


Receive Message


Process Message


Generate Response


Continue Workflow

Each communication step should be reliable, traceable, and fault tolerant.


Communication Participants

AI agents communicate with multiple systems.

                AI Agent
    ┌───────────────┼─────────────────┐
    ▼               ▼                 ▼
 Other Agents      Humans          External APIs
    │                                   │
    ▼                                   ▼
 Message Queue                   Enterprise Systems

Communication is not limited to agent-to-agent interactions.

Agents frequently communicate with:

  • Other AI agents
  • Human users
  • APIs
  • Databases
  • Enterprise applications
  • Workflow engines

Communication Models

Enterprise AI systems commonly use several communication models.


1. Direct Communication

One agent directly invokes another.

Planner


Developer

Characteristics

  • Simple
  • Low latency
  • Tight coupling

Typical Uses

  • Small agent systems
  • Local workflows

2. Message-Based Communication

Messages are exchanged through a broker.

Agent


Message Queue


Agent

Characteristics

  • Loose coupling
  • Reliable delivery
  • Scalable

Typical Uses

  • Enterprise AI platforms
  • Distributed agents

3. Event-Driven Communication

Agents react to events.

Order Created


Event Bus


Inventory Agent


Shipping Agent


Billing Agent

Characteristics

  • Asynchronous
  • Highly scalable
  • Decoupled

Typical Uses

  • Business workflows
  • Enterprise automation

4. Shared Memory Communication

Agents exchange information through a common memory store.

Agent A


Shared Memory


Agent B

Characteristics

  • Shared context
  • Easy collaboration
  • Simple coordination

Typical Uses

  • Multi-agent reasoning
  • Shared planning

Communication Patterns

Different workflows require different communication strategies.

Pattern Typical Use Case
Direct Calls Small workflows
Message Queue Distributed systems
Publish-Subscribe Event processing
Shared Memory Collaborative reasoning
Request-Response Tool invocation
Broadcast Multi-agent notifications

Choosing the Right Communication Pattern

Scenario Recommended Pattern
Single workflow Direct Communication
Multi-agent collaboration Shared Memory
Enterprise automation Event-Driven
Distributed AI platform Message Queue
External APIs Request-Response
Notifications Publish-Subscribe

Implementation

Example 1 – Core Python

A simple direct communication example.

class PlannerAgent:

    def create_task(self):
        return "Generate project documentation"


class DocumentationAgent:

    def execute(self, task):
        print(f"Executing: {task}")


planner = PlannerAgent()
documentation = DocumentationAgent()

task = planner.create_task()

documentation.execute(task)

Output

Executing: Generate project documentation

This demonstrates synchronous communication between two agents.


Example 2 – LangGraph

LangGraph enables communication through shared workflow state.

from typing import TypedDict
from langgraph.graph import StateGraph

class AgentState(TypedDict):
    task: str
    result: str

workflow = StateGraph(AgentState)

workflow.add_node("planner", planner_node)
workflow.add_node("developer", developer_node)
workflow.add_node("tester", tester_node)

Each node communicates by reading from and writing to the shared workflow state rather than directly invoking other agents.


Example 3 – Production Example (Kafka)

Enterprise AI systems commonly use Kafka for asynchronous communication.

from kafka import KafkaProducer
import json

producer = KafkaProducer(
    bootstrap_servers="localhost:9092",
    value_serializer=lambda v: json.dumps(v).encode("utf-8")
)

producer.send(
    "agent-tasks",
    {
        "agent": "documentation",
        "task": "Generate API documentation"
    }
)

producer.flush()

Instead of directly invoking another agent, the task is published to a Kafka topic. Any authorized agent subscribed to the topic can consume and process the message, enabling scalable and loosely coupled multi-agent architectures.


Enterprise Use Cases

Software Development Assistant

Multiple specialized agents collaborate to complete software development tasks.

Examples

  • Requirement Analysis Agent
  • Architecture Agent
  • Code Generation Agent
  • Testing Agent
  • Documentation Agent
Developer


Supervisor Agent


Planner


Code Generator


Tester


Documentation Agent


Final Solution

Each agent communicates its output to the next stage of the workflow.


Customer Support Platform

Customer support systems commonly consist of several specialized agents.

Examples

  • Intent Detection Agent
  • Knowledge Retrieval Agent
  • Ticket Management Agent
  • Escalation Agent
  • Feedback Agent

Instead of a single agent handling everything, each agent performs one specialized task and communicates the results.


Financial Services

Enterprise banking systems often orchestrate multiple AI agents.

Examples

  • Fraud Detection Agent
  • Risk Assessment Agent
  • Compliance Agent
  • Recommendation Agent
  • Customer Notification Agent

Each agent exchanges structured messages while maintaining auditability.


Healthcare Assistant

Healthcare AI systems require collaboration among multiple agents.

Examples

  • Patient Intake Agent
  • Diagnosis Assistant
  • Medical Knowledge Agent
  • Treatment Recommendation Agent
  • Appointment Scheduling Agent

Communication ensures that every agent contributes to the final recommendation without duplicating work.


Enterprise Workflow Automation

Large organizations automate business workflows using communicating agents.

Invoice Received


Validation Agent


Approval Agent


Payment Agent


Notification Agent


ERP System

Each agent performs a specific business operation and communicates completion before the workflow proceeds.


Production Insight

Enterprise AI agents rarely communicate through direct method calls.

Instead, communication is routed through messaging infrastructure.

                 Supervisor Agent
                Communication Layer
      ┌─────────────────┼──────────────────┐
      ▼                 ▼                  ▼
   Kafka          RabbitMQ         Redis Streams
      │                 │                  │
      ▼                 ▼                  ▼
 Planner Agent   Coding Agent     Testing Agent

This architecture provides:

  • Loose coupling
  • Independent deployment
  • Horizontal scalability
  • Fault tolerance
  • Reliable message delivery

Large enterprise AI platforms almost always separate business logic from communication infrastructure.


Architecture Decision

Scenario Recommended Communication Pattern
Single application Direct Communication
Microservices Message Queue
Event-driven workflows Publish-Subscribe
Shared planning Shared Memory
External API integration Request-Response
Long-running workflows Event Bus
Enterprise AI Platform Kafka + Workflow Engine
Multi-Agent Systems Message Queue + Shared Memory

Advantages

  • Enables collaboration between specialized agents
  • Supports distributed AI architectures
  • Improves scalability
  • Enables asynchronous execution
  • Reduces coupling between agents
  • Improves fault tolerance
  • Simplifies workflow orchestration

Limitations

  • Additional infrastructure requirements
  • Increased architectural complexity
  • Message ordering challenges
  • Network latency
  • Error handling becomes more complex
  • Distributed debugging is more difficult

Best Practices

  • Keep messages small and self-contained.
  • Use structured message formats (JSON, Protobuf, Avro).
  • Design communication to be asynchronous whenever possible.
  • Avoid direct dependencies between specialized agents.
  • Implement retry and dead-letter queue strategies.
  • Use correlation IDs for request tracing.
  • Version message schemas.
  • Monitor communication latency and failures.

Common Mistakes

❌ Creating tightly coupled agents

❌ Using synchronous communication everywhere

❌ Sending large payloads between agents

❌ Ignoring message versioning

❌ No retry strategy

❌ Missing correlation IDs

❌ No communication monitoring

❌ Mixing business logic with messaging logic


Framework Comparison

Framework Communication Model
LangChain Chains, Tool Calling, Runnable Pipelines
LangGraph Shared Graph State, Directed Workflow Edges
CrewAI Agent-to-Agent Collaboration
AutoGen Conversational Multi-Agent Messaging
OpenAI Agents SDK Tool Invocation & Session Context
Google ADK Workflow & Agent Coordination

Interview Questions

What is Agent Communication?

Why is communication important in multi-agent systems?

What is the difference between direct communication and message-based communication?

When should event-driven communication be preferred?

Why are message queues commonly used in enterprise AI systems?

What is shared memory communication?

How does asynchronous communication improve scalability?

What challenges arise in distributed agent communication?


Quick Revision

                 AI Agents
          Communication Layer
      ┌──────────────┼──────────────┐
      ▼              ▼              ▼
 Direct Call   Message Queue   Event Bus
      │              │              │
      ▼              ▼              ▼
 Shared Memory   Request-Response  Publish-Subscribe
              External Systems

Key Takeaways

  • Agent Communication enables AI agents to collaborate, coordinate tasks, and exchange information efficiently.
  • Enterprise AI platforms use multiple communication models, including direct communication, message queues, publish-subscribe, event-driven architectures, and shared memory.
  • Modern production systems rely on messaging infrastructure such as Kafka, RabbitMQ, or Redis Streams to achieve scalability, reliability, and loose coupling.
  • Choosing the appropriate communication pattern depends on workflow complexity, latency requirements, scalability goals, and deployment architecture.
  • Effective communication is the foundation of multi-agent systems, distributed AI platforms, and enterprise workflow automation.

References

  • LangGraph Documentation – Multi-Agent Workflows
  • CrewAI Documentation – Agent Collaboration
  • AutoGen Documentation – Multi-Agent Conversations
  • Apache Kafka Documentation
  • RabbitMQ Documentation
  • Redis Streams Documentation

Next Note

02-message-passing.md

In the next note, we'll explore Message Passing, the most fundamental communication mechanism in multi-agent systems. You'll learn synchronous vs. asynchronous messaging, message structure, delivery guarantees, serialization formats, routing strategies, acknowledgments, retries, and production implementations using Kafka, RabbitMQ, Redis Streams, and cloud messaging services.

Enterprise AI Engineering Handbook
Building Production-Grade Enterprise AI Systems — One Chapter at a Time.