Skip to content

Delegation

Delegation allows an orchestrator agent to assign tasks to specialist agents. The orchestrator coordinates work without executing tasks directly.

How It Works

  1. Orchestrator receives a task from the user
  2. Orchestrator queries the agent pool (GET /api/agents/pool) to see available specialists
  3. Orchestrator delegates via POST /api/agents/delegate
  4. Specialist executes the task and returns a response
  5. Orchestrator receives the result and continues

Pool Mode vs Chat Mode

Toggle in the chat toolbar:

ModeBehavior
PoolOrchestrator delegates via HTTP API to dedicated specialist agents
ChatAgent uses SDK native subagents (Agent tool) within its own session

Setting Up Delegation

  1. Create a workspace with .claude/commands/*.md files defining roles
  2. Set one role as orchestrator (workspace settings or agent toggle)
  3. Spawn the orchestrator and specialist agents
  4. 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:

StatusMeaning
queuedTask waiting in specialist's queue
workingSpecialist is executing
doneTask completed, response available
errorTask 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.

Released under the MIT License.