Agent Hive is a production-ready orchestration operating system for autonomous AI agents. It enables seamless coordination across different LLM providers (Claude, Grok, Gemini, etc.) using shared memory stored in Markdown files.
Inspiration: Some patterns in Agent Hive were inspired by beads, particularly the ready work detection, dependency tracking, and MCP integration concepts. We've adapted these ideas for our Markdown-first, vendor-agnostic approach.
Instead of building vendor-specific workflows, Agent Hive uses a simple but powerful primitive: AGENCY.md - a Markdown file with YAML frontmatter that serves as shared memory between AI agents, humans, and automation.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GLOBAL.md β
β (Root System State) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββ΄βββββββββββ
β β
ββββββββΌββββββ ββββββββΌββββββ
β AGENCY.md β β AGENCY.md β
β (Project 1)β β (Project 2)β
ββββββββ¬ββββββ ββββββββ¬ββββββ
β β
βββββββββββββΌββββββββββββ β
β β β β
βββββΌβββ βββββΌβββ βββββΌβββ βββββΌββββ
βClaudeβ β Grok β βGeminiβ β Human β
ββββββββ ββββββββ ββββββββ βββββββββ
This repository practices what it preaches. The projects/ directory contains real projects being actively coordinated by Cortex:
- Cortex runs every 4 hours via GitHub Actions (see
.github/workflows/cortex.yml) - Project updates are committed automatically - you can watch orchestration happen in real-time
- The
projects/directory shows live work - not just demos, but actual coordination
Browse the projects/ directory to see:
- Active projects with assigned owners
- Blocked tasks waiting for dependencies
- Agent notes documenting progress
- Task completion over time
When you fork this repository:
- The Cortex workflow won't run (it requires the
OPENROUTER_API_KEYsecret) - The Claude Code workflow won't run (it requires the
ANTHROPIC_API_KEYsecret) - Add your API keys in repository settings to enable them (Settings β Secrets and variables β Actions)
- Your fork becomes your own independent Hive
This transparency demonstrates that Agent Hive is a real, working system - not just a concept.
- Python 3.11+
- uv - Fast Python package installer
- OpenRouter API key (Get one here)
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/intertwine/hive-orchestrator.git
cd hive-orchestrator
# Install dependencies with uv
make install
# Create .env file
make setup-env
# Edit .env and add your API key
nano .envOPENROUTER_API_KEY=your-api-key-here
OPENROUTER_MODEL=anthropic/claude-haiku-4.5
HIVE_BASE_PATH=/path/to/agent-hive
# Optional: Real-time coordination server
COORDINATOR_URL=http://localhost:8080make dashboardOpen http://localhost:8501 in your browser.
make cortexThis runs the orchestration engine that analyzes all projects and updates state.
agent-hive/
βββ .claude/
β βββ skills/ # Claude Code skills for Agent Hive
β βββ hive-project-management/
β βββ cortex-operations/
β βββ deep-work-session/
β βββ multi-agent-coordination/
β βββ hive-mcp/
βββ .devcontainer/
β βββ devcontainer.json # DevContainer config (Codespaces/Cursor ready)
βββ .github/
β βββ workflows/
β βββ cortex.yml # Automated 4-hour heartbeat
β βββ agent-assignment.yml # Automated agent work dispatch
βββ config/
β βββ app-manifest.json # GitHub App definition (for SaaS)
βββ examples/
β βββ */ # Example workflows (7 patterns)
βββ projects/
β βββ */ # Your project workspaces
β βββ AGENCY.md # Project shared memory
βββ scripts/
β βββ start_session.sh # Deep Work session bootstrap
βββ src/
β βββ cortex.py # Orchestration logic
β βββ agent_dispatcher.py # Automated agent work assignment
β βββ context_assembler.py # Issue context builder
β βββ coordinator.py # Real-time coordination server (optional)
β βββ coordinator_client.py # Coordinator client library
β βββ dashboard.py # Streamlit UI
β βββ security.py # Security utilities (YAML, sanitization, auth)
β βββ tracing.py # Weave observability integration
β βββ hive_mcp/ # MCP server for AI agents
β βββ __init__.py
β βββ __main__.py
β βββ server.py # MCP tool implementations
βββ tests/ # Test suite (150+ tests)
βββ articles/ # Documentation articles
βββ GLOBAL.md # Root system state
βββ Makefile # Convenience commands
βββ pyproject.toml # Python project configuration & dependencies
βββ SECURITY.md # Security policy and hardening documentation
βββ README.md # This fileEvery project has an AGENCY.md file with:
---
project_id: my-project
status: active
owner: null
last_updated: 2025-01-15T10:30:00Z
blocked: false
blocking_reason: null
priority: high
tags: [feature, backend]
dependencies:
blocked_by: [other-project] # This project waits for these
blocks: [downstream-project] # These projects wait for us
parent: epic-project # Part of a larger epic (optional)
related: [context-project] # Related but non-blocking (optional)
---
# Project Title
## Objective
What this project aims to achieve.
## Tasks
- [ ] Task 1
- [ ] Task 2
- [x] Completed task
## Agent Notes
- **2025-01-15 10:30 - Claude**: Started work on Task 1Key Fields:
| Field | Description |
|---|---|
project_id |
Unique identifier for the project |
status |
active, pending, blocked, or completed |
owner |
Agent currently working (or null if unclaimed) |
blocked |
true if blocked on external dependency |
priority |
low, medium, high, or critical |
dependencies.blocked_by |
Projects that must complete before this one |
dependencies.blocks |
Projects waiting on this one |
cortex.py reads all AGENCY.md files, calls an LLM to analyze the state, and updates files accordingly. It:
- β Never executes code blindly
- β Only updates Markdown frontmatter
- β Identifies blocked tasks
- β Suggests new project creation
- β Runs every 4 hours via GitHub Actions
- β Ready Work Detection - Find actionable projects without LLM calls
- β Dependency Tracking - Build and analyze dependency graphs
- β Cycle Detection - Prevent deadlocks from circular dependencies
CLI Commands:
# Full orchestration run (uses LLM)
make cortex
# Fast ready work detection (no LLM, instant)
make ready # Human-readable output
make ready-json # JSON for programmatic use
# Dependency analysis (no LLM, instant)
make deps # Human-readable dependency graph
make deps-json # JSON for programmatic usedashboard.py is a Streamlit app that:
- π Visualizes all projects
- π Generates "Deep Work" contexts
- π§ Triggers Cortex manually
- π Displays task lists and metadata
- π Shows dependency graphs and blocking status
β οΈ Alerts on dependency cycles
The hive-mcp server enables AI agents like Claude to interact with Agent Hive programmatically via the Model Context Protocol.
Available Tools:
| Tool | Description |
|---|---|
list_projects |
List all discovered projects with metadata |
get_ready_work |
Get projects ready for an agent to claim |
get_project |
Get full details of a specific project |
claim_project |
Set owner field to claim work |
release_project |
Set owner to null |
update_status |
Change project status |
add_note |
Append to agent notes section |
get_dependencies |
Get dependency info for a project |
get_dependency_graph |
Get full dependency graph |
coordinator_status |
Check if coordination server is available |
coordinator_claim |
Claim project via coordination server |
coordinator_release |
Release project via coordination server |
coordinator_reservations |
Get all active reservations |
Claude Desktop Configuration:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"hive": {
"command": "uv",
"args": ["run", "python", "-m", "hive_mcp"],
"env": {
"HIVE_BASE_PATH": "/path/to/your/agent-hive"
}
}
}
}Run Standalone:
uv run python -m hive_mcpThe Coordinator Server provides an optional real-time coordination layer for scenarios where multiple agents need to work concurrently without git conflicts.
Note: This is fully optional. Agent Hive works perfectly with git-only coordination. The Coordinator is for teams wanting faster real-time conflict resolution.
Start the server:
# Default: localhost:8080
uv run python -m src.coordinator
# Custom host/port
COORDINATOR_HOST=0.0.0.0 COORDINATOR_PORT=9000 uv run python -m src.coordinatorConfigure clients:
# Add to .env
COORDINATOR_URL=http://localhost:8080API Endpoints:
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check with active claim count |
/claim |
POST | Claim a project (returns 409 if already claimed) |
/release/{project_id} |
DELETE | Release a project claim |
/status/{project_id} |
GET | Check claim status of a project |
/reservations |
GET | List all active reservations |
/extend/{project_id} |
POST | Extend claim TTL |
Claim Request Example:
curl -X POST http://localhost:8080/claim \
-H "Content-Type: application/json" \
-d '{"project_id": "my-project", "agent_name": "claude-opus", "ttl_seconds": 3600}'Response (Success - 200):
{
"success": true,
"claim_id": "uuid-here",
"project_id": "my-project",
"agent_name": "claude-opus",
"expires_at": "2025-01-01T12:00:00Z"
}Response (Conflict - 409):
{
"success": false,
"error": "Project already claimed",
"current_owner": "grok-beta",
"claimed_at": "2025-01-01T10:00:00Z",
"expires_at": "2025-01-01T11:00:00Z"
}Features:
- Automatic claim expiration (configurable TTL, default 1 hour)
- Force-claim option for admin override (
?force=true) - Background cleanup of expired claims
- Graceful degradation (clients fall back to git-only when unavailable)
- OpenAPI documentation at
/docs
The Agent Dispatcher proactively finds ready work and assigns it to Claude Code by creating GitHub issues.
Prerequisite: The Agent Dispatcher requires the Claude Code GitHub App to be installed on your repository for
@claudementions to work.
How it works:
- Finds ready work - Uses Cortex to discover unblocked, unowned projects
- Selects highest priority - Priority level first, then age (oldest first)
- Builds rich context - AGENCY.md content, file trees, relevant files
- Creates GitHub issue - With
@claudemention to trigger Claude Code - Claims the project - Sets
owner: "claude-code"in AGENCY.md
Run manually:
# Dispatch highest priority ready project
uv run python -m src.agent_dispatcher
# Dry run (preview without changes)
uv run python -m src.agent_dispatcher --dry-run
# Dispatch up to 3 projects
uv run python -m src.agent_dispatcher --max 3GitHub Actions:
The Agent Dispatcher runs automatically every 4 hours (15 minutes after Cortex) via .github/workflows/agent-assignment.yml.
Claude Code Integration:
When issues are created with @claude mentions, the Claude Code Action (.github/workflows/claude.yml) automatically responds. This enables Claude to:
- Analyze code and implement requested changes
- Create pull requests for bug fixes and features
- Answer questions about the codebase
Requires ANTHROPIC_API_KEY secret to be configured.
AGENCY.md Extension - relevant_files:
Specify files to include in the issue context:
---
project_id: my-project
relevant_files:
- src/api/routes.py
- src/models/user.py
- tests/test_api.py
---Agent Hive can coordinate work on external GitHub repositories. Add a target_repo field to your AGENCY.md:
---
project_id: improve-external-lib
status: active
target_repo:
url: https://github.com/org/external-repo
branch: main
---
# Improve External Library
## Tasks
- [ ] Analyze repository structure
- [ ] Identify improvement opportunity
- [ ] Implement and submit PR
## Phase 1: Analysis
*Agent writes analysis here*
## Phase 2: Strategy
*Agent writes improvement plan here*
## Phase 3: Implementation
*Agent writes code changes here*When the Dispatcher creates an issue for this project, it automatically:
- Clones the external repo (shallow, depth=1)
- Generates a file tree (4 levels deep, excludes noise like node_modules)
- Reads key files (package.json, README.md, src/index.*, etc.)
- Includes context in the issue for the agent
- Cleans up temporary files
The agent then works on the external repository while using AGENCY.md as shared memory. Results are written to Phase sections, and when ready, the agent submits a PR to the target repository.
See also:
Let GitHub Actions run Cortex every 4 hours. It will:
- Read all AGENCY.md files
- Identify blocked tasks
- Update project statuses
- Commit changes back to the repo
# Enable the workflow
git push origin main
# Monitor runs
gh workflow view cortex.ymlUse the bootstrap script to generate context for manual agent work:
make session PROJECT=projects/demoThis creates a SESSION_CONTEXT.md file with:
- Full AGENCY.md content
- File tree
- Handoff instructions
- Persona guidelines
Copy this to your AI agent (Claude, Cursor, etc.) and let it work.
Different agents can work on the same project:
- Agent A (Claude): Does research, updates AGENCY.md
- Cortex: Detects completion, marks next task
- Agent B (Grok): Picks up next task, continues work
- Human: Reviews in Dashboard, adds new tasks
Edit .env to change the model:
# Fast and cheap (default)
OPENROUTER_MODEL=anthropic/claude-haiku-4.5
# More capable
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
# Alternative providers
OPENROUTER_MODEL=google/gemini-pro
OPENROUTER_MODEL=x-ai/grok-betaAgent Hive includes built-in observability via Weights & Biases Weave. Weave automatically traces all LLM calls, capturing latency, token usage, and costs.
Enable Weave tracing:
# Add to .env
WANDB_API_KEY=your-wandb-api-key
WEAVE_PROJECT=agent-hive # Optional, defaults to "agent-hive"Disable tracing (optional):
WEAVE_DISABLED=trueWhat gets traced:
- All LLM API calls to OpenRouter
- Request/response latency (milliseconds)
- Token usage (prompt, completion, total)
- Success/failure status
- Cortex orchestration runs
Key features:
- Automatic header sanitization: API keys are redacted from traces
- Graceful degradation: If Weave fails or isn't configured, the app continues normally
- Decorators for custom tracing: Use
@trace_op("name")to trace your own functions - LLMCallMetadata: Rich metadata class capturing all call details
View traces:
- Log into wandb.ai
- Navigate to your Weave project
- View call traces, costs, and performance metrics
Tracing is optional and gracefully degrades - if Weave is not configured or fails to initialize, the application continues to function normally.
Agent Hive includes comprehensive security hardening. See SECURITY.md for full details.
Required for production:
# Add to .env for Coordinator API authentication
HIVE_API_KEY=your-secure-api-key-here
HIVE_REQUIRE_AUTH=trueSecurity features:
- Safe YAML parsing: Prevents deserialization attacks (RCE prevention)
- Prompt injection protection: Sanitizes untrusted content before LLM calls
- API key authentication: Bearer token auth for Coordinator server
- Path traversal validation: Prevents directory escape attacks
- Input validation: Bounds checking on dispatch limits and recursion depth
- Issue body sanitization: Filters injection patterns in GitHub issues
Environment variables:
| Variable | Purpose | Default |
|---|---|---|
HIVE_API_KEY |
Coordinator authentication | None (required for external access) |
HIVE_REQUIRE_AUTH |
Enable/disable auth | true in production |
COORDINATOR_HOST |
Server binding address | 127.0.0.1 (localhost only) |
For detailed security documentation, see the Security article and SECURITY.md.
Edit .github/workflows/cortex.yml:
schedule:
# Run every 2 hours instead of 4
- cron: "0 */2 * * *"The Claude Code GitHub App is required for the Agent Dispatcher to work. It responds to @claude mentions in issues and pull requests.
Installation:
- Visit https://github.com/apps/claude
- Click "Install" or "Configure"
- Select your organization or account
- Choose "Only select repositories" and add this repository
- Click "Install"
Verify installation:
# Run the verification script
uv run python scripts/verify_claude_app.py
# Test the dispatcher (dry run)
uv run python -m src.agent_dispatcher --dry-runFor detailed instructions, see docs/INSTALL_CLAUDE_APP.md.
To deploy Agent Hive as your own custom GitHub App (for webhooks/SaaS):
- Go to GitHub Settings > Developer > GitHub Apps > New GitHub App
- Use
config/app-manifest.jsonas the base configuration - Set webhook URL to your server
- Install on repositories
src/cortex.py- Core orchestration logicsrc/dashboard.py- Streamlit UIscripts/start_session.sh- Session bootstrap.devcontainer/- DevContainer configuration
make testmake formatmake lint- Create a directory in
projects/:
mkdir projects/my-new-project- Create an
AGENCY.mdfile (copy fromprojects/demo/AGENCY.md):
cp projects/demo/AGENCY.md projects/my-new-project/AGENCY.md- Edit the frontmatter and content:
---
project_id: my-new-project
status: active
owner: null
last_updated: null
blocked: false
priority: high
tags: [new-feature]
---
# My New Project
## Objective
Build a new feature that...- Run Cortex:
make cortexThe project will now be tracked automatically.
Already configured! Just push to GitHub and enable Actions.
Required Secrets (Settings β Secrets and variables β Actions):
OPENROUTER_API_KEY- For Cortex orchestration engineANTHROPIC_API_KEY- For Claude Code Action (@claude mentions)
# Add to crontab
0 */4 * * * cd /path/to/agent-hive && python src/cortex.pyDeploy to AWS/GCP/Azure with:
- Cron job running Cortex
- Nginx serving Dashboard
- GitHub App webhook receiver
Open in GitHub Codespaces for instant MCP-enabled environment:
# The DevContainer is pre-configured
# Just open in Codespaces and run:
make dashboardAgent Hive provides two levels of MCP integration:
The built-in hive-mcp server gives AI agents direct access to Agent Hive operations:
# Install and run
uv run python -m hive_mcpThis enables agents to:
- π List and query projects programmatically
- π― Find ready work without scanning files
- π Claim/release projects atomically
- π Update status and add notes
- π Navigate dependency graphs
See Hive MCP Server for configuration.
The DevContainer also includes a generic filesystem MCP server for lower-level file operations. When using Cursor/Claude Code in the DevContainer, agents have filesystem access for reading/writing files directly.
Agent Hive includes a set of Claude Code Skills that teach Claude how to work effectively with the orchestration system. Skills are modular instruction sets that Claude loads automatically when relevant to your task.
| Skill | Description | Use When |
|---|---|---|
| hive-project-management | Managing AGENCY.md files, frontmatter fields, task tracking | Creating/updating projects, managing ownership |
| cortex-operations | Running Cortex CLI, dependency analysis, ready work detection | Finding work, analyzing dependencies, running orchestration |
| deep-work-session | Focused work sessions, handoff protocol, session lifecycle | Starting/ending work sessions, following protocols |
| multi-agent-coordination | Multi-agent patterns, conflict prevention, coordination server | Working with other agents, preventing conflicts |
| hive-mcp | MCP server tools, programmatic project access | Using MCP tools for project management |
Skills use progressive disclosure - Claude loads only the skill name and description at startup, then loads full instructions when needed:
1. Startup: Load skill metadata (name + description)
2. Task Match: Claude detects relevant skill from your request
3. Activation: Full skill instructions loaded into context
4. Execution: Claude follows skill guidance for the taskSkills are stored in .claude/skills/ with this structure:
.claude/skills/
βββ hive-project-management/
β βββ SKILL.md
βββ cortex-operations/
β βββ SKILL.md
βββ deep-work-session/
β βββ SKILL.md
βββ multi-agent-coordination/
β βββ SKILL.md
βββ hive-mcp/
βββ SKILL.mdSkills activate automatically based on your request. Examples:
# Activates: hive-project-management
"Create a new project for the authentication feature"
# Activates: cortex-operations
"Find projects that are ready for me to work on"
# Activates: deep-work-session
"Start a deep work session on the demo project"
# Activates: multi-agent-coordination
"How do I coordinate with other agents on this project?"
# Activates: hive-mcp
"Use the MCP tools to claim project demo"Each skill provides comprehensive guidance:
- hive-project-management: AGENCY.md structure, all frontmatter fields, task management, ownership rules, dependency configuration
- cortex-operations: CLI commands (
--ready,--deps,--json), output interpretation, troubleshooting, programmatic usage - deep-work-session: Session lifecycle (enter β claim β work β update β handoff), checklist, blocking protocol
- multi-agent-coordination: Ownership protocol, dependency flow, coordinator API, conflict resolution patterns
- hive-mcp: All 12 MCP tools with arguments, response formats, workflow examples
You can add custom skills or install from the Anthropic Skills repository:
# Create a new skill
mkdir .claude/skills/my-custom-skill
cat > .claude/skills/my-custom-skill/SKILL.md << 'EOF'
---
name: my-custom-skill
description: Description of what this skill does and when to use it
---
# My Custom Skill
Instructions for Claude to follow...
EOFAgent Hive is built on these principles:
- Vendor Agnostic: Works with any LLM provider
- Human-in-the-Loop: Always transparent, never autonomous
- Simple Primitives: Markdown files as shared memory
- Git as Source of Truth: All state is versioned
- Free Infrastructure: Runs on GitHub Actions free tier
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE file for details.
Edit your .env file and add your API key from https://openrouter.ai/
Make sure you have at least one AGENCY.md file in a subdirectory of projects/.
- Check that the workflow is enabled in your repo settings
- Ensure
OPENROUTER_API_KEYis set as a repository secret - Verify the cron schedule in
.github/workflows/cortex.yml
# Reinstall dependencies
make install
# Or sync dependencies
make sync
# Check for port conflicts
lsof -i :8501Completed:
- Ready work detection (fast, no LLM required)
- Dependency tracking with cycle detection
- MCP server for AI agent integration
- JSON output mode for programmatic access
- Dashboard dependency visualization
- Real-time agent coordination layer (HTTP API)
- Claude Code Skills for guided AI workflows
- Automated agent work assignment (Agent Dispatcher)
- Security hardening (YAML RCE, prompt injection, auth)
- Weave tracing integration (LLM observability)
- Multi-repository support
Planned:
- Web-based Dashboard (hosted version)
- Slack/Discord integration
- Agent performance metrics
- Visual workflow builder
- Docker deployment for coordinator
- GitHub Issues: https://github.com/intertwine/hive-orchestrator/issues
- Discussions: https://github.com/intertwine/hive-orchestrator/discussions
Built with β€οΈ by the Agent Hive community.
Happy orchestrating! π
