inter-agent-communication
Inter-Agent Communication
Inter-Agent Communication defines the language and transport layer for agents to talk to each other. In a distributed system, Agent A (Booking) might run on a different server than Agent B (Payment). They need a standard way to find each other (Discovery), send requests (Messaging), and understand the data format (Protocol).
When to Use
- Microservices Architecture: Breaking a monolithic agent into smaller, deployable services.
- Ecosystem Integration: Allowing your agent to talk to agents built by other teams or companies.
- Asynchronous Tasks: "Fire and forget" tasks where Agent A sends a job to Agent B and checks back later.
- Load Balancing: Distributing tasks across a pool of identical agents.
Use Cases
- Agent Marketplace: An agent searches a registry to find a "Translation Agent" and hires it for a task.
- Supply Chain: A "Retail Agent" sends a restock order to a "Warehouse Agent", which confirms availability.
- Delegation: A "Personal Assistant Agent" delegates a math problem to a specialized "Wolfram Alpha Agent".
Implementation Pattern
# Conceptual A2A (Agent-to-Agent) Interaction
class AgentA:
def run(self):
# Step 1: Discovery
# Find an agent that supports the 'payment' skill
payment_agent_url = directory.lookup(skill="process_payment")
# Step 2: Messaging (HTTP/RPC)
# Send a structured request
payload = {
"task": "pay_invoice",
"amount": 100,
"currency": "USD"
}
response = http.post(f"{payment_agent_url}/inbox", json=payload)
# Step 3: Handle Response
if response.status == "CONFIRMED":
print("Payment successful")
Examples
Input: An orchestrator agent distributing research tasks to specialist agents.
# Orchestrator sends task
orchestrator.send(Message(
to="researcher-agent-1",
task="Find all SEC filings for AAPL in 2024",
context={"output_format": "json", "deadline": "2025-03-01"}
))
# Researcher replies
researcher.send(Message(
to="orchestrator",
status="complete",
result=filings_data,
metadata={"sources": 14, "latency_ms": 3200}
))
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Messages lost | No delivery acknowledgement | Require ACK from receiver; use at-least-once delivery with idempotency keys |
| Agents talk past each other | No shared schema | Define a typed message schema (Pydantic/JSON Schema) for all message types |
| Deadlock between agents | Circular dependency | Design a strict orchestrator hierarchy; no peer-to-peer blocking calls |
| Message queue backs up | Slow consumer agent | Add horizontal scaling or a priority queue for time-sensitive messages |
More from lauraflorentin/skills-marketplace
multi-agent-collaboration
A structural pattern where multiple specialized agents communicate and coordinate to solve a problem that is too complex for a single agent. Use when user asks to "build a multi-agent system", "agents working together", "agent collaboration", or mentions team of agents, distributed agents, or swarm.
21reflection
A recursive pattern where an agent evaluates and critiques its own output to iteratively improve quality and catch errors. Use when user asks to "add self-reflection", "agent introspection", "self-critique", or mentions self-evaluation, meta-cognition, or quality self-assessment.
18human-in-the-loop
A hybrid pattern where the system pauses execution to request human approval, input, or disambiguation before proceeding with critical actions. Use when user asks to "add human approval", "require human review", "human-in-the-loop", or mentions approval workflows, human oversight, or escalation.
16planning
A high-level cognitive pattern where an agent formulates a structured sequence of actions (a plan) before executing any of them, ensuring goal-directed behavior. Use when user asks to "add planning to my agent", "task planning", "agent planning", or mentions plan generation, plan execution, or step-by-step planning.
14parallelization
A concurrency pattern where multiple agent tasks are executed at the same time to speed up processing or gather diverse perspectives. Use when user asks to "run agents in parallel", "parallelize tasks", "concurrent execution", or mentions parallel processing, fan-out, or batch execution.
13routing
A control flow pattern where a central component classifies an input request and directs it to the most appropriate specialized agent or tool. Use when user asks to "route between agents", "agent routing", "task dispatch", or mentions classifier routing, intent detection, or agent selection.
12