Delegation
Delegation allows an orchestrator agent to assign tasks to specialist agents. The orchestrator coordinates work without executing tasks directly.
How It Works
- Orchestrator receives a task from the user
- Orchestrator queries the agent pool (
GET /api/agents/pool) to see available specialists - Orchestrator delegates via
POST /api/agents/delegate - Specialist executes the task and returns a response
- Orchestrator receives the result and continues
Pool Mode vs Chat Mode
Toggle in the chat toolbar:
| Mode | Behavior |
|---|---|
| Pool | Orchestrator delegates via HTTP API to dedicated specialist agents |
| Chat | Agent uses SDK native subagents (Agent tool) within its own session |
Setting Up Delegation
- Create a workspace with
.claude/commands/*.mdfiles defining roles - Set one role as orchestrator (workspace settings or agent toggle)
- Spawn the orchestrator and specialist agents
- Send a task to the orchestrator — it will delegate automatically
Delegation Rules
The orchestrator receives these rules in its system prompt:
- Idle agent → delegate directly
- Agent not spawned → spawn first, wait 3 seconds, then delegate
- 2+ parallel tasks → use spawn-request (requires user approval)
Delegation Status
Each delegation shows as a card in the orchestrator's chat:
| Status | Meaning |
|---|---|
queued | Task waiting in specialist's queue |
working | Specialist is executing |
done | Task completed, response available |
error | Task failed |
Spawn Requests
When the orchestrator needs multiple specialists simultaneously, it sends a spawn request. A card appears in the chat for the user to approve or deny, with checkboxes for each requested role.
Non-Orchestrator Blocking
Non-orchestrator agents receive a system prompt instruction to execute tasks directly using their own tools, not delegate. The delegation API endpoint returns 403 for non-orchestrators.
Queue Management
Each specialist has a sequential queue. If multiple delegations arrive:
- They execute one at a time (FIFO)
- The stop button drains the queue, rejecting pending tasks
- Results are sent back to the orchestrator as system messages
Pool Context Optimization
The delegation rules (~500 tokens) are injected once in the system prompt. A refresh is sent every 10 turns to prevent context loss after auto-compact.