| name | multi-agent-coordination |
| description | Coordinate work between multiple AI agents in Agent Hive. Use this skill when multiple agents need to collaborate, managing dependencies between projects, preventing conflicts, using the coordination server, or understanding multi-agent workflows. |
Multi-Agent Coordination
Agent Hive enables coordination between multiple AI agents (Claude, Grok, Gemini, etc.) using shared memory and optional real-time coordination. This skill covers patterns for effective multi-agent collaboration.
Coordination Layers
Agent Hive provides three coordination mechanisms:
1. Git-Based (Always Available)
- AGENCY.md files as shared memory
- Git commits track all state changes
- Pull/push for synchronization
- Works with any agent or environment
2. Cortex Orchestration (Automated)
- Runs every 4 hours via GitHub Actions
- Analyzes system state with LLM
- Identifies blocked tasks
- Updates project metadata
3. Real-Time Coordinator (Optional)
- FastAPI server for immediate coordination
- Prevents simultaneous claims
- TTL-based reservations
- Best for parallel agent sessions
Ownership Protocol
Claiming Ownership
Before working, an agent must claim the project:
# In AGENCY.md frontmatter
owner: "claude-sonnet-4" # Your agent identifier
Ownership Rules
- Only claim unclaimed projects - Check
owner: null - One owner at a time - Never override another agent
- Release when done - Set
owner: nullafter work - Respect claims - If claimed, find another project
Agent Identifiers
Use consistent naming for agent identification:
| Provider | Example Identifier |
|---|---|
| Anthropic Claude | claude-sonnet-4, claude-opus-4 |
| OpenAI | gpt-4-turbo, gpt-4o |
gemini-pro, gemini-ultra |
|
| X.AI | grok-beta, grok-2 |
| Custom | my-agent-v1, research-bot |
Dependency Management
Defining Dependencies
Use the dependencies field in AGENCY.md:
dependencies:
blocked_by: [auth-feature, database-setup] # Must wait for these
blocks: [frontend-integration] # These wait for us
parent: main-project # Hierarchical relationship
related: [docs-project] # Informational link
Dependency Flow
[auth-feature] ─────┐
├──> [api-integration] ──> [frontend-integration]
[database-setup] ───┘
Checking Dependencies
Before starting work, verify dependencies are met:
# Check dependency status
uv run python -m src.cortex --deps
# Or via Cortex Python API
from src.cortex import Cortex
cortex = Cortex()
blocking_info = cortex.is_blocked("my-project")
Real-Time Coordinator
The optional coordination server prevents conflicts during parallel agent sessions.
Starting the Server
# Start coordinator
uv run python -m src.coordinator
# Or with custom settings
COORDINATOR_HOST=0.0.0.0 COORDINATOR_PORT=8080 uv run python -m src.coordinator
Using the Coordinator
Check Status
curl http://localhost:8080/health
Claim a Project
curl -X POST http://localhost:8080/claim \
-H "Content-Type: application/json" \
-d '{"project_id": "my-project", "agent_name": "claude-sonnet-4", "ttl_seconds": 3600}'
Release a Claim
curl -X DELETE http://localhost:8080/release/my-project
View All Reservations
curl http://localhost:8080/reservations
Coordinator API Reference
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check and status |
/claim |
POST | Claim a project |
/release/{project_id} |
DELETE | Release by project ID |
/release/claim/{claim_id} |
DELETE | Release by claim ID |
/status/{project_id} |
GET | Check project status |
/reservations |
GET | List all active claims |
/extend/{project_id} |
POST | Extend claim TTL |
TTL (Time-To-Live)
Claims automatically expire after TTL:
- Default: 3600 seconds (1 hour)
- Maximum: 86400 seconds (24 hours)
- Extend before expiration to continue working
Multi-Agent Patterns
1. Sequential Handoff
Agents work one after another on the same project:
Agent A (Research) -> Agent B (Design) -> Agent C (Implementation)
Protocol:
- Agent A completes work, adds notes, sets
owner: null - Agent B sees unclaimed project, claims it
- Agent B reads Agent A's notes, continues work
- Repeat for Agent C
2. Parallel Independence
Multiple agents work on independent projects simultaneously:
Agent A -> [Project 1]
Agent B -> [Project 2]
Agent C -> [Project 3]
Protocol:
- Each agent claims different project
- No coordination needed during work
- Use coordinator for claim management
3. Dependency Chain
Projects with sequential dependencies:
Agent A -> [Project 1] ──blocks──> Agent B -> [Project 2]
Protocol:
- Agent B waits for Project 1 completion
- Agent A sets
status: completed - Cortex detects completion
- Agent B sees Project 2 ready, claims it
4. Ensemble Collaboration
Multiple agents contribute to same project:
[Research Project]
├── Agent A: Sources 1-3
├── Agent B: Sources 4-6
└── Agent C: Synthesis
Protocol:
- Create sub-tasks in AGENCY.md
- Agents claim specific tasks via notes
- Use atomic task markers
- Final agent synthesizes contributions
Conflict Resolution
Optimistic Locking (Git)
If two agents modify the same file:
- Git merge conflict occurs
- Later agent must resolve
- Review both changes
- Commit resolved version
Pessimistic Locking (Coordinator)
Coordinator prevents conflicts upfront:
- First agent claims successfully
- Second agent gets 409 Conflict
- Second agent works on different project
- First agent releases when done
Conflict Prevention Tips
- Use coordinator for parallel sessions
- Claim before reading - Minimize race window
- Short sessions - Reduce conflict probability
- Clear boundaries - Define task ownership in notes
- Check before claiming - Always verify
owner: null
Communication via Agent Notes
Agents communicate through the Agent Notes section:
## Agent Notes
- **2025-01-15 16:00 - grok-beta**: Completed API integration.
@claude-sonnet-4 - the auth module needs your review before merge.
- **2025-01-15 15:00 - claude-sonnet-4**: Starting auth implementation.
Will coordinate with grok-beta on API integration.
- **2025-01-15 14:00 - gemini-pro**: Initial research complete.
Key findings: [summary]. Recommending approach B for implementation.
Note Conventions
- @agent-name - Direct mention for specific agent
- BLOCKED - Prefix for blocking issues
- TODO - Items for next agent
- DECISION - Record important choices
Best Practices
- Always check ownership first - Never override another agent
- Use coordinator for speed - Faster than git-only coordination
- Keep notes detailed - Other agents depend on your documentation
- Release promptly - Don't hold claims unnecessarily
- Manage dependencies - Keep
blocked_by/blocksaccurate - Plan handoffs - Document what's done and what's next
- Respect the protocol - Coordination only works if everyone follows it