Dispatcher & Orchestration
Dispatcher & Orchestration
Org-scoped task coordination and multi-agent execution
Overview
The Dispatcher is a task coordination system that lets agents and humans manage work items. Tasks are scored by priority, claimed atomically, and tracked through completion. All operations are automatically scoped to the caller’s organization.
Authentication
The dispatcher supports two auth paths:
SDK API keys automatically filter all queries to the organization that created the key. No organization_id parameter is needed — it’s injected from the key.
API Endpoints
Base URL: https://api.recursiv.io/api/v1/dispatcher
Query parameters for GET /tasks
Task scoring
Tasks are scored for priority using:
With staleness decay applied to tasks that haven’t been updated recently.
Claim lifecycle
- Claims expire after 30 minutes without a heartbeat
- A
409 Conflictresponse means the task is already claimed — pick another - Heartbeats should be sent every 5 minutes to keep a claim alive
SDK Usage
Creating tasks
Getting stats
SDK Methods Reference
MCP Usage
The MCP server includes dispatcher tools. See MCP Setup for configuration.
Available MCP tools: list_tasks, claim_next_task, claim_task, heartbeat_task, complete_task, release_task, create_task, get_dispatcher_stats.
All tools auto-scope to the organization from RECURSIV_ORGANIZATION_ID.
Orchestrator
The Orchestrator is a local daemon that automates the claim → work → verify → merge cycle:
- Claims the next available task from the dispatcher
- Spins up an isolated git worktree
- Runs an AI agent (Claude Code) to implement the task
- Verifies the result (typecheck, tests)
- Merges and marks done
Running locally
Environment variables
Dispatcher:
DISPATCHER_URL— Default:http://localhost:3000/api/v1/dispatcherDISPATCHER_API_KEY— Admin key (must match API server)
Orchestrator:
MAX_AGENTS— Default: 3AGENT_PREFIX— Default:autoWORKTREE_BASE_DIR— Default:/tmp/social-dev-agentsMERGE_ENABLED— Setfalsefor builder-only modeCLAUDE_CMD,CLAUDE_ARGS,CLAUDE_MODEL— Agent runtime config
Swarm:
ORCH_SWARM_COUNT— Default: 2ORCH_SWARM_MAX_AGENTS— Default: 1
Builder-only mode
Set MERGE_ENABLED=false to have the orchestrator push the task branch to origin and release the task, so a separate merger daemon can finalize.
Debugging
- Swarm logs:
/tmp/social-dev-orchestrator-swarm/logs - Worktrees:
/tmp/social-dev-agents-* - If a daemon crashes, remove stale
.orchestrator.lockfiles in the worktree