agent-communication
Skill4 starsChanged 9 months agoMITView on GitHub
Patterns for inter-agent communication including message passing, shared state, event-driven architectures, pub/sub, inbox/outbox, and structured vs freeform messages. Use when the user is building systems where multiple agents need to communicate, share information, coordinate work, or pass data between processing stages.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- codeaholicguy/ai-devkittheir own version, first seen Sep 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- codeaholicguy/ai-devkit★ 1.6ksame name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository78 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/agents.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/claude-initial-setup.mdcCursor rule
- parallel-task-executionSkill
- subagent-patternsSkill
- task-coordinationSkill
- context-managementSkill
- multi-agent-orchestrationSkill
- deploy-strategiesSkill
- github-actions-guideSkill
- pipeline-patternsSkill
- anthropic-sdk-guideSkill
- prompt-engineeringSkill
- tool-use-patternsSkill
- automated-review-setupSkill
- pr-standardsSkill
- review-checklistSkill
- file-organizationSkill
- immutability-patternsSkill
- naming-conventionsSkill
- branching-strategySkill
- commit-conventionsSkill
- pr-workflowSkill
- migration-patternsSkill
- query-optimizationSkill
- schema-design-guideSkill
- error-tracingSkill
- log-analysisSkill
- systematic-debuggingSkill
- django-admin-customizationSkill
- django-orm-masterySkill
- drf-api-patternsSkill
- docker-compose-guideSkill
- dockerfile-best-practicesSkill
- multi-stage-buildsSkill
- express-error-handlingSkill
- middleware-patternsSkill
- rest-api-nodeSkill
- async-fastapiSkill
- dependency-injection-fastapiSkill
- pydantic-validationSkill
- concurrency-patterns-goSkill
- error-handling-goSkill
- idiomatic-goSkill
- automation-triggersSkill
- hook-recipesSkill
- pre-post-hooksSkill
- junit-testingSkill
- maven-gradle-guideSkill
- spring-boot-patternsSkill
- mcp-resource-patternsSkill
- mcp-server-creationSkill
- mcp-tool-designSkill
- context-optimizationSkill
- knowledge-persistenceSkill
- memory-patternsSkill
- caching-strategiesSkill
- lazy-loading-patternsSkill
- profiling-guideSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 213
Not including correlation IDs to link requests with responses
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Communication
Patterns for communication between AI agents. Covers message passing, shared state, event-driven design, pub/sub, inbox/outbox, and structured message formats.
When to Use
- User is building multi-agent systems that need inter-agent communication
- User needs shared state between agents
- User wants event-driven agent coordination
- User is designing message formats for agent-to-agent data exchange
- User asks about pub/sub or inbox/outbox patterns for agents
Core Patterns
Direct Message Passing
Agents communicate through explicit function calls with typed messages.
from dataclasses import dataclass
from typing import Any
@dataclass(frozen=True)
class AgentMessage:
sender: str
recipient: str
msg_type: str # "request", "response", "notification"
payload: dict
correlation_id: str # Links requests to responses
class MessageBus:
def __init__(self):
self._handlers: dict[str, list] = {}
self._inbox: dict[str, list[AgentMessage]] = {}
def register(self, agent_id: str, handler):
self._handlers[agent_id] = handler
self._inbox[agent_id] = []
def send(self, message: AgentMessage):
self._inbox[message.recipient].append(message)
async def deliver(self, agent_id: str) -> list[AgentMessage]:
messages = self._inbox[agent_id]
self._inbox[agent_id] = []
return messages
# Usage
bus = MessageBus()
bus.send(AgentMessage(
sender="orchestrator",
recipient="researcher",
msg_type="request",
payload={"task": "Find recent papers on RAG optimization"},
correlation_id="task-001"
))Shared State Store
Agents read and write to a shared state store for coordination.
import asyncio
from dataclasses import dataclass, field
@dataclass(frozen=True)
class StateEntry:
value: Any
updated_by: str
version: int
class SharedState:
def __init__(self):
self._state: dict[str, StateEntry] = {}
self._lock = asyncio.Lock()
self._watchers: dict[str, list] = {}
async def get(self, key: str) -> StateEntry | None:
return self._state.get(key)
async def put(self, key: str, value: Any, agent_id: str) -> StateEntry:
async with self._lock:
current = self._state.get(key)
version = (current.version + 1) if current else 1
entry = StateEntry(value=value, updated_by=agent_id, version=version)
self._state = {**self._state, key: entry} # Immutable update
# Notify watchers
for callback in self._watchers.get(key, []):
await callback(key, entry)
return entry
def watch(self, key: str, callback):
watchers = self._watchers.get(key, [])
self._watchers = {**self._watchers, key: [*watchers, callback]}
# Usage
state = SharedState()
await state.put("research_findings", {"papers": [...]}, agent_id="researcher")
await state.put("code_review", {"issues": [...]}, agent_id="reviewer")
# Another agent reads the state
findings = await state.get("research_findings")Event-Driven Architecture
Agents react to events rather than being explicitly called.
@dataclass(frozen=True)
class Event:
event_type: str
source: str
data: dict
timestamp: float
class EventBus:
def __init__(self):
self._subscribers: dict[str, list[Callable]] = {}
def subscribe(self, event_type: str, handler: Callable[[Event], Awaitable[None]]):
handlers = self._subscribers.get(event_type, [])
self._subscribers = {**self._subscribers, event_type: [*handlers, handler]}
async def publish(self, event: Event):
await asyncio.gather(*[h(event) for h in self._subscribers.get(event.event_type, [])])
# Agents subscribe to event types they care about
event_bus = EventBus()
event_bus.subscribe("code_submitted", code_analyzer) # Triggers analysis
event_bus.subscribe("analysis_complete", test_generator) # Triggers test genPub/Sub with Topics
Agents subscribe to topics and receive relevant messages without tight coupling.
class PubSub:
def __init__(self):
self._topics: dict[str, list[str]] = {}
self._queues: dict[str, asyncio.Queue] = {}
def subscribe(self, agent_id: str, topic: str):
subscribers = self._topics.get(topic, [])
self._topics = {**self._topics, topic: [*subscribers, agent_id]}
if agent_id not in self._queues:
self._queues[agent_id] = asyncio.Queue()
async def publish(self, topic: str, message: dict, sender: str):
for agent_id in self._topics.get(topic, []):
if agent_id != sender:
await self._queues[agent_id].put({"topic": topic, "sender": sender, "message": message})
async def receive(self, agent_id: str, timeout: float = 30.0) -> dict | None:
try:
return await asyncio.wait_for(self._queues[agent_id].get(), timeout=timeout)
except asyncio.TimeoutError:
return None
# Usage
pubsub = PubSub()
pubsub.subscribe("security_agent", "code_changes")
pubsub.subscribe("test_agent", "code_changes")
await pubsub.publish("code_changes", {"file": "auth.py", "diff": "..."}, sender="developer")Structured Message Formats
Define typed schemas for agent-to-agent communication instead of free-form text.
from dataclasses import dataclass
from enum import Enum
class TaskStatus(Enum):
PENDING = "pending"
IN_PROGRESS = "in_progress"
COMPLETED = "completed"
FAILED = "failed"
@dataclass(frozen=True)
class TaskRequest:
task_id: str
task_type: str # "research", "code", "review", "test"
instruction: str
context: dict
priority: int # 1 (highest) to 5 (lowest)
@dataclass(frozen=True)
class TaskResponse:
task_id: str
status: TaskStatus
result: dict | None = None
error: str | None = None
tokens_used: int = 0Anti-Patterns
- Using unstructured free-form text between agents (hard to parse, error-prone)
- Polling shared state in tight loops instead of using watchers or events
- Not including correlation IDs to link requests with responses
- Agents modifying each other's state directly instead of through messages
- Missing error handling in message delivery (lost messages, silent failures)
- Circular event chains without termination conditions (infinite loops)
- Mutable shared state without locking (race conditions in concurrent agents)
Quick Reference
| Pattern | Best For | Coupling |
| Direct message | Point-to-point requests | High |
| Shared state | Configuration, results store | Medium |
| Event-driven | Reactive pipelines | Low |
| Pub/sub | Broadcasting to interested agents | Low |
Key guidelines: use structured messages over free-form text, include correlation IDs, prefer immutable message objects, log all inter-agent messages, set timeouts on receives.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

