Overview
The Model Router scores the complexity of every agent request and routes it to the cheapest capable model tier. This keeps costs low for simple interactions (greetings, status checks) while ensuring complex tasks (code architecture, multi-step reasoning) get powerful models.Tier Definitions
Tier model assignments are configurable per profile and can be overridden in
~/.argentos/argent.json:
Complexity Scoring Algorithm
ThescoreComplexity() function evaluates 7 factors and produces a score between 0 and 1:
Factor 1: Prompt Length
Factor 2: Thinking Level
The user’s thinking level preference adds a boost:Thinking level is treated as a signal of desired reasoning depth, not as an automatic tier escalation. A user who always sets
xhigh but sends “hey” still routes to the appropriate tier.Factor 3: Image Input
If the request includes images (requires vision-capable models):Factor 4: Session Type
The session type applies floors, caps, and boosts:Factor 5: Tool-Likely Prompt Detection
For user-facing sessions, the router detects prompts likely to trigger tool use:Factor 6: Code/Technical Content
Detection patterns include code blocks, programming keywords (
function, class, import), SQL statements, and infrastructure terms (docker, kubernetes).
Factor 7: Reasoning/Analysis Patterns
Detection patterns include analysis verbs (
analyze, compare, evaluate), trade-off language, step-by-step requests, and system design requests.
Score Reduction: Simple Queries
Simple greetings and acknowledgments (hi, hello, hey, thanks, ok, yes, no) reduce the score, keeping trivial interactions on the cheapest tier.
Background Model Lanes
Five background subsystems have dedicated routing:Named Routing Profiles
Profiles define complete tier mappings and fallback chains:Built-in Profiles
ArgentOS ships with several built-in profiles includingdefault, budget, minimax-mix, and others defined in src/models/builtin-profiles.ts. User-defined profiles in config take precedence.
Profile Chaining
Profiles can chain to fallback profiles:Cross-Provider Fallback
When a provider fails (rate limit, error, unavailability), the router walks the fallback chain:- Primary: The tier’s configured model/provider
- Profile fallback: Next model in the profile’s fallback chain
- Cross-provider: Different provider for the same tier
Cycle Detection
The fallback walker tracks visited profiles to prevent infinite loops:Provider Normalization
The router normalizes provider names to handle common variations:It also infers providers from model names (
claude-* -> anthropic, gpt-* -> openai, glm-* -> zai, etc.) to handle misconfigured profiles.Dashboard Model Badge
The dashboard displays a color-coded badge on each message showing which tier was used:Session Model Override
Individual sessions can override the router with a specific model:Memory Query Boost
Memory recall queries receive a +0.25 score boost to ensure they route to at least the FAST tier. Local models lack the context window and reasoning needed to effectively process retrieved memories and synthesize them into useful responses.
Configuration
Full router configuration in~/.argentos/argent.json:
Disabling the Router
Setenabled: false to bypass routing and always use the default model:
