Delegated routing: Brainstorm CLI delegates model selection to BR's 13 intelligence systems
2026-03-24
What We Built
POST /v1/route — a delegated routing endpoint that accepts task metadata from Brainstorm CLI and returns the optimal model selected by BrainstormRouter's Thompson sampling, auto-selection, circuit breakers, and ranking engine. Instead of local heuristic-only classification, every brainstorm instance now benefits from production performance data across all BR clients.
The endpoint translates Brainstorm's task profile (type, complexity, capabilities needed, budget constraints) into an AutoSelectRequest, delegates to the existing ModelAutoSelector, and enriches the response with bandit context (sample count, reward mean/variance) and ranked alternatives.
Why It Matters
Local model classifiers are heuristic-only — they guess which model is best based on static rules. Delegated routing replaces guessing with evidence: Thompson sampling learns from every request across every tenant. A new Brainstorm user gets optimal routing from day one because they inherit the collective intelligence of the entire fleet.
How It Works
const result = await client.routing.recommend({
task: { type: "refactoring", complexity: "complex", requires_tool_use: true },
capabilities_needed: ["code-generation", "tool-calling"],
constraints: { max_cost_usd: 0.1 },
});
// → { model: "anthropic/claude-sonnet-4-5", confidence: 0.87, ... }
The endpoint wires 5 intelligence systems: ModelAutoSelector (capability matching + complexity assessment), ModelBandit (Thompson sampling), ModelPerformanceTracker (reward statistics), CircuitBreakerManager (health exclusion), and RankingEngine (alternatives).
Lockstep Checklist
- [x] API Routes:
src/api/routes/routing.ts— new POST /v1/route - [x] TS SDK:
packages/sdk-ts/src/resources/routing.ts— addedrecommend()method - [x] Python SDK:
packages/sdk-py/src/brainstormrouter/resources/routing.py— addedrecommend()method - [x] MCP Schemas:
br_route_recommendtool added to manifest and server