← Home System Overview Architecture Data Pipeline Health System Usage System Workflows MCP Tools

Data Pipeline — The Brain

Blueprint · Last updated 2026-05-02

Request Flow

  1. Claude calls delegate.py with --provider, --type, --prompt, and optionally --context flags.
  2. delegate.py constructs a Task object containing the prompt, task type, context, and preferred provider.
  3. orchestrator.py receives the Task and looks up the fallback chain for task_type in router.py.
  4. The orchestrator invokes the adapter for the preferred provider first.
  5. On adapter failure: logs the failure, advances to the next provider in the chain, retries.
  6. On success: stats.py appends the call metadata to stats/usage.json and 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 TypePrimary ProviderEarly Fallbacks
classificationcerebrasgroq → cloudflare
factual_qacerebrasgroq → cloudflare → gemini
summarizationgeminimistral → sambanova
codingmistralfireworks → sambanova
reasoningsambanovamistral → gemini → fireworks
creativemistralsambanova → gemini
translationgeminimistral → cerebras
extractionmistralsambanova → gemini
generalcerebrasgroq → 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.