agent-relay
Agent-to-agent messaging for AI coding tools. Let Claude, Gemini, GPT, and human devs coordinate in real time.
No server. No database. No config. Just the filesystem.
[]
= "0.1"
The problem
You have 3 Claude sessions, a Gemini agent, and a human all editing the same repo. Claude #1 starts refactoring auth.rs. Claude #2 has no idea and starts editing the same file. Gemini rewrites a function that Claude #1 just deleted. The human comes back to merge conflicts everywhere.
The fix
# Install
# Claude session 1
# Claude session 2 checks before editing
# [NEW] claude (claude-1): refactoring auth module, stay away from src/auth/
# Gemini replies
# Human checks what's happening
# SESSION AGENT PID HEARTBEAT
# claude-1 claude 12345 08:31:20
# claude-2 claude 12346 08:31:22
# gemini-1 gemini 12400 08:31:25
Library API
use PathBuf;
use Relay;
let relay = new;
// Register
relay.register;
// Send (None = broadcast to all)
relay.send;
// DM a specific agent
relay.send;
// Check inbox (marks messages as read)
let msgs = relay.inbox;
for in &msgs
// Poll for new messages (for integration into loops)
let count = relay.poll;
if count > 0
CLI Commands
| Command | Description |
|---|---|
register --agent NAME --session ID |
Register an agent |
unregister --session ID |
Remove an agent |
send MESSAGE |
Broadcast a message |
send --to SESSION MESSAGE |
DM a specific agent |
inbox --session ID |
Read messages (marks as read) |
unread --session ID |
Count unread messages |
agents |
List active agents |
cleanup |
Remove dead agents + old messages |
watch --session ID --exec CMD |
Poll for new messages, optionally run a command |
Watch mode
Auto-trigger a command when messages arrive:
# Spawn Claude to respond when new messages come in
# Or just get notified
How it works
- One JSON file per message in
.relay/messages/ - One JSON file per agent in
.relay/agents/ - Read tracking: each message has a
read_byarray - Dead agents cleaned up by PID check
- Old messages cleaned up by timestamp
- Atomic writes (tmp + rename) prevent corruption
All agents that point to the same .relay directory see each other. That's the entire protocol.
Integration with AI tools
Claude Code (CLAUDE.md)
Before editing any file, check for team messages:
$ agent-relay inbox --session $SESSION_ID
Gemini / Cursor / Windsurf
Same pattern — add relay commands to your agent's system prompt or MCP tool definitions.
MCP Server
Wrap agent-relay as an MCP tool server so AI agents can call relay_send, relay_inbox, etc. natively. (Coming in v0.2)
Origin
Extracted from Aura — the semantic version control engine for AI-generated code. Aura uses agent-relay's messaging protocol to coordinate multiple Claude Code agents editing the same repository.
License
Apache-2.0