A simple, file-based communication system for coordinating multiple AI agents or processes. Designed for WSL/Ubuntu environments where agents run in separate terminals.
- File-based messaging - No network dependencies, uses local filesystem
- JSON message format - Structured, extensible messages
- Multiple agent support - Dynamic agent registration
- Message persistence - Messages survive agent restarts
- Status monitoring - Real-time agent activity tracking
- Cleanup automation - Automatic archiving and cleanup
- Dashboard - Live system monitoring
cd ~/projects/agent_system
./scripts/setup.shFollow prompts to add aliases to your ~/.bashrc.
Send a message:
agent-send alice bob TASK "Search for patterns in file.txt"Check messages:
agent-recv bob listProcess one message:
agent-recv bob process-oneMonitor system:
agent-monitorCheck status:
agent-status| Type | Purpose | Example |
|---|---|---|
TASK |
Work assignment | "Search for X in Y" |
RESULT |
Task completion | "Found 5 matches" |
ERROR |
Error reporting | "File not found" |
STATUS |
Status update | "Processing 50%" |
CONTROL |
System control | "Restart session" |
HEARTBEAT |
Keepalive | "Agent alive" |
agent_system/
├── inbox/ # Incoming messages per agent
│ ├── alice/ # Messages for 'alice'
│ └── bob/ # Messages for 'bob'
├── outbox/ # Sent messages per agent
├── archive/ # Processed messages
├── status/ # Agent status files
├── logs/ # System logs
├── sessions/ # Agent session state
├── config/ # Configuration files
└── scripts/ # Core scripts
Send a message to another agent.
Usage:
agent-send <from_agent> <to_agent> <message_type> <content> [metadata_json]Example:
agent-send claude opencode TASK 'Read file /tmp/test.txt' '{"priority": "high", "timeout": 30}'Manage received messages.
Usage:
agent-recv <agent_name> [action] [options]Actions:
list- List all messages in inbox (default)peek <id>- View a specific messageprocess- Process all messages (move to archive)process-one- Process the oldest messagecount- Count messages in inboxpurge <days>- Purge old archived messages (default: 7 days)
Check system or agent status.
Usage:
agent-status [agent_name]Without arguments, shows system-wide status.
Real-time monitoring dashboard.
Usage:
agent-monitor [refresh_interval_seconds]Default refresh: 5 seconds. Press Ctrl+C to exit.
Clean up old files.
Usage:
agent-clean [days_to_keep] [dry_run]Default: Keep 7 days. Set dry_run to "true" or "1" for dry run.
Terminal 1 (Claude as master):
# Send task to opencode
agent-send claude opencode TASK "Find all .cpp files in project"
# Wait for response
sleep 2
agent-recv claude listTerminal 2 (Opencode as worker):
# Check for tasks
agent-recv opencode process-one
# Execute task...
# Send result back
agent-send opencode claude RESULT "Found 15 .cpp files"Create a worker script:
#!/bin/bash
while true; do
# Check for tasks
COUNT=$(agent-recv worker count)
if [ "$COUNT" -gt 0 ]; then
# Process one task
agent-recv worker process-one
# ... execute task ...
# Send result
agent-send worker master RESULT "Task completed"
fi
sleep 5
doneAgents automatically update their status when using the scripts. Check agent activity:
agent-status # Shows all agents with last activity timeMessages are stored as JSON files:
{
"id": "msg_1742901234_12345",
"from": "claude",
"to": "opencode",
"type": "TASK",
"timestamp": 1742901234,
"content": "Search for pattern in file",
"metadata": {
"priority": "high",
"scheduled_for": 0,
"timeout": 30,
"routed": true,
"score": 42
}
}Messages can have different priority levels that affect processing order:
- critical - Highest priority, processed first
- high - High priority tasks
- medium - Default priority
- low - Low priority tasks
- default - Same as medium
Set priority in metadata:
agent-send alice bob TASK "Urgent task" '{"priority": "critical"}'Messages are processed in priority order (highest first), then by age.
Send messages for future delivery with scheduled_for:
# Schedule for 5 minutes from now
SCHEDULED=$(($(date +%s) + 300))
agent-send alice bob TASK "Future task" "{\"scheduled_for\": $SCHEDULED}"Use the scheduler daemon to deliver scheduled messages:
# Run once
./scripts/scheduler.sh --once
# Run as background daemon
./scripts/scheduler.sh --daemon --interval 60Route tasks to the most suitable agent based on capabilities, availability, and priority:
# Find agent with specific capability
route_task.sh claude "Analyze code" --capability code_analysis
# High priority task with capability matching
route_task.sh claude "Critical fix" --priority critical --capability bug_fix
# Route directly to specific agent
route_task.sh claude "Run tests" --to testerRouting considers:
- Agent capabilities and type
- Recent activity (availability)
- Priority (high priority tasks favor agents with
high_prioritycapability) - Custom metadata
For detailed protocol specifications and agent development guidelines, see AGENTS.md.
Edit config/default.json to customize:
- Message TTL (time-to-live)
- Maximum message size
- Cleanup intervals
- Logging settings
- Priority levels and weights
- Scheduler interval and max scheduled days
jq- JSON processingbash4.0+- Standard Unix utilities (
date,find,mkdir, etc.)
Install missing dependencies:
sudo apt-get install jq- Use descriptive agent names:
claude,opencode,explorer,tester - Include metadata: Add context like priority, timeout, requirements
- Set appropriate priorities: Use "critical" only for urgent tasks, "low" for background work
- Schedule non-urgent tasks: Use
scheduled_forfor time-sensitive operations - Regular cleanup: Run
agent-cleanperiodically or add to cron - Monitor activity: Use
agent-monitorduring active sessions - Handle errors: Check message counts and agent status regularly
- Use smart routing: Leverage
route_task.shfor capability-based task assignment
- Master agent splits codebase into sections
- Sends sections to multiple worker agents
- Workers analyze in parallel
- Results aggregated by master
- Agent A runs tests
- Agent B analyzes logs
- Agent C examines code
- All share findings via messages
- Build agent compiles code
- Test agent runs tests
- Report agent generates summaries
- All coordinated through message system
"jq not found": Install with sudo apt-get install jq
"Permission denied": Make scripts executable with chmod +x scripts/*.sh
Messages not appearing: Check directory permissions and agent names match
Large log files: Run agent-clean regularly
- Add custom message handlers: Modify
receive_messages.shto execute tasks - Integrate with APIs: Create wrapper scripts that interface with external systems
- Add encryption: Encrypt message content for sensitive data
- Network transport: Extend to communicate between machines
MIT License - See LICENSE file (to be added)
- Fork the repository
- Create feature branch
- Add tests
- Submit pull request