Agent Routing
How Betwixt matches each sub-task to the optimal AI model based on capability, cost, and latency.
Agent routing is the process by which Niko selects the best model for each sub-task. Rather than sending every request to a single model, Betwixt evaluates multiple factors to make an intelligent routing decision.
Routing Strategies
Betwixt supports five routing strategies, configurable per project or per request:
Capability-Based Routing
The default strategy. Each model is scored on a set of capabilities (code generation, reasoning, multimodal understanding, etc.), and the model with the highest score for the required capability wins.
Cost-Optimized Routing
Routes to the cheapest model that meets a minimum quality threshold. Useful for high-volume tasks where cost matters more than peak performance.
Latency-Optimized Routing
Selects the model with the lowest expected response time. Ideal for interactive use cases where speed is critical.
Quality-First Routing
Always selects the highest-quality model regardless of cost or latency. Best for critical tasks like security reviews or architectural decisions.
Round-Robin
Distributes tasks evenly across all configured providers. Useful for load distribution and comparative evaluation.
How Routing Decisions Are Made
When Niko decomposes a task, each sub-task is tagged with:
- Required capabilities -- What skills the model needs (e.g., code generation, long-context reasoning)
- Priority level -- How critical quality is for this particular sub-task
- Context size -- How much context the model will need to process
- Output expectations -- Whether the output is code, prose, structured data, or analysis
The LLM Mesh evaluates these tags against the capability profiles of all configured providers and selects the optimal match.
Model Capability Profiles
Each provider has a capability profile maintained by Betwixt:
| Capability | Claude | Codex | Gemini |
|---|---|---|---|
| Code generation | High | Highest | Medium |
| Reasoning | Highest | Medium | High |
| Long context | High | Low | Highest |
| Multimodal | Medium | Low | Highest |
| Cost efficiency | Medium | High | High |
These profiles are continuously updated based on benchmark results and real-world performance data.
Fallback Behavior
If the selected provider is unavailable or rate-limited, Betwixt automatically falls back to the next-best option. The fallback chain is:
- Try the primary selected model
- If unavailable, try the second-ranked model for the same capability
- If all preferred models are unavailable, queue the task and retry with exponential backoff
You are never left without a response -- Betwixt handles provider failures transparently.
Configuring Routing
You can set the default routing strategy in your project configuration:
bx config set routing.strategy capabilityOr override per-request by adding a routing hint to your prompt:
[routing: cost] Generate boilerplate CRUD endpoints for the users tableNext Steps
Now that you understand routing, start your first session to see it in action.