Request Flow
- Claude calls
delegate.pywith--provider,--type,--prompt, and optionally--contextflags. delegate.pyconstructs aTaskobject containing the prompt, task type, context, and preferred provider.orchestrator.pyreceives theTaskand looks up the fallback chain fortask_typeinrouter.py.- The orchestrator invokes the adapter for the preferred provider first.
- On adapter failure: logs the failure, advances to the next provider in the chain, retries.
- On success:
stats.pyappends the call metadata tostats/usage.jsonand the result is printed to stdout.
Fallback Chain
Each task_type has an ordered fallback chain in router.py. All attempts are logged regardless of outcome. Example for coding:
mistral → fireworks → sambanova → cerebras → groq → gemini
→ openai → ollama → openrouter → huggingface → cohere → pollinations
Task Type Dispatch
| Task Type | Primary Provider | Early Fallbacks |
|---|---|---|
classification | cerebras | groq → cloudflare |
factual_qa | cerebras | groq → cloudflare → gemini |
summarization | gemini | mistral → sambanova |
coding | mistral | fireworks → sambanova |
reasoning | sambanova | mistral → gemini → fireworks |
creative | mistral | sambanova → gemini |
translation | gemini | mistral → cerebras |
extraction | mistral | sambanova → gemini |
general | cerebras | groq → cloudflare → gemini |
MCP Mode
When running as an MCP server via mcp_server.py, the same orchestrator is invoked by the delegate tool. Claude calls it natively — no Bash required. The response is returned as TextContent with a header line:
[mistral / mistral-small-latest | 512 tokens | 1172ms | free]
<content>
Context Window
The optional --context parameter is prepended to the prompt before sending to the provider. Used to pass document text to summarization tasks, or file contents to coding tasks, without inflating the main prompt.