In April 2026, a growth-stage SaaS company with 35 engineers received an API bill for $87,000. Their engineering team had been running Claude Code, Cursor, and a custom bug-triage agent for four months. No one had set a model routing policy. Every step in every agent loop — file reads, routine code edits, tool routing decisions, validation passes — defaulted to Opus 4.7. The bill was not caused by careless developers. It was caused by an architectural decision no one had made explicitly: which model handles which task.
By May, after implementing model tier routing, prompt caching, and context pruning, the same team's bill was $24,000. Annual savings: $756,000. Engineering productivity, measured by sprint velocity, was unchanged.
This is the model routing problem condensed to a single case study. The expensive model was doing work the cheap model handles just as well. No one had told it otherwise.
Why the Wrong Model Costs More Than You Think
The core issue is not that frontier AI models are expensive — it is that most agentic frameworks default to a single model for everything. That model is usually a mid-tier or frontier option, because that is what produced the best demo results. In production, it handles file reads, variable extractions, tool routing decisions, and boilerplate code edits at the same per-token price as architectural reasoning and multi-file debugging.
The math compounds quickly. A LeanOps audit of 30 engineering teams running agentic AI (March–May 2026) found that re-sent context accounts for 62% of the average agent API bill — not actual reasoning output, but the same system prompts, tool definitions, and conversation history re-sent on every step. Every LLM API call is stateless. The provider does not remember your previous turn. So agents send the entire accumulated history on every tool call, every validation, every re-check.
By step 20 in a loop with file reads, the input on a single call can exceed 50,000 tokens. At Claude Sonnet 4.6's input rate, one late-loop step alone costs $0.15. Multiply by 50 steps, 50 tasks per developer per day, and 20 developers over a 22-day month: you are approaching $110,000 per month before any budget alert has fired.
The LeanOps audit found a 20x spread between the 10th and 90th percentile developer cost for teams using ostensibly the same tool. The difference was almost entirely which model developers defaulted to and whether prompt caching was enabled. Two engineers, identical tools, wildly different bills.
The Model Tier Routing Pattern
Model tier routing assigns different agent steps to different model tiers based on the cognitive demand of each step. The principle is to use the cheapest model that produces acceptable output for each step type, and reserve expensive models for the steps that genuinely require frontier reasoning.
A practical three-tier structure for 2026 model families:
Tier 1 — Routine steps: File reading, variable extraction, structured data parsing, tool selection from a small menu, boilerplate code edits. These tasks are well-defined, have correct/incorrect answers, and do not benefit from frontier reasoning. Models: Haiku 4.5, GPT-5 Nano, Gemini 2.5 Flash-Lite. Cost: roughly 1/20th of a frontier model call.
Tier 2 — Standard reasoning: Code review, test writing, API integration, single-file refactoring, summarization. Most of an agent's real work falls here. Models: Claude Sonnet 4.6, GPT-5, Gemini 2.5 Pro. Cost: roughly 1/5th of a frontier model call.
Tier 3 — Hard reasoning: Architectural decisions, multi-file refactors with subtle dependency chains, security analysis, root-cause diagnosis on complex bugs. This is where frontier models earn their cost. Models: Opus 4.7, GPT-5.5. The remaining step types in this category — complex architecture decisions, multi-file refactors with non-obvious dependency chains — genuinely benefit from frontier-level reasoning, and benchmark data from both Anthropic and OpenAI shows meaningful performance gaps between frontier and mid-tier models on these task classes.
A workflow that routes 80% of steps to Haiku 4.5 and escalates only the hard 20% to Opus 4.7 produces 60–80% savings compared to an all-Opus workflow, according to the LeanOps audit — with comparable end results on standard workloads. That single routing decision, applied uniformly across an engineering team, accounts for the majority of the $87K → $24K reduction in the LeanOps case study.
What Observability Tools Miss
The default response to high agent costs is to install an observability platform. LangSmith, Langfuse, Helicone, and Arize all offer cost dashboards, per-trace spend breakdowns, and spend-per-agent visibility. These are useful. They are also insufficient.
Visibility tools tell you that costs are high after the money has been spent. They do not prevent the routing decision that sent a file-read step to Opus 4.7. The incident described by the builder of AgentBudget on Hacker News (May 2026) — a GPT-4o retry loop that cost $187 in 10 minutes — was not an observability failure. The developer could have watched it happen in LangSmith in real time. The failure was the absence of runtime enforcement: no rule that said "if this step type is a retry and per-call cost exceeds a threshold, stop and escalate."
This is the distinction between monitoring and governance. Monitoring surfaces data. Governance enforces rules.
There is also a compounding irony: LangSmith's per-trace pricing adds its own overhead — $2.50 per 1,000 base traces, $5.00 per 1,000 extended traces — which compounds at high-volume deployments. Teams pay for observability while continuing to route everything to the wrong model — watching the bill grow in a dashboard they cannot act on.
How Waxell Runtime Enforces Model Routing
Waxell Runtime applies model routing and cost rules at the governance layer — above agent code, without requiring rebuilds. Rather than modifying each agent's internal routing logic or patching individual framework libraries, Runtime enforces token budgets and model tier policies as configuration: specific step types are capped to specific model tiers, per-session hard stops prevent runaway loops, and budget thresholds trigger rerouting or escalation rather than continued execution.
Waxell Observe, which instruments over 200 libraries automatically with 2 lines of code, provides the real-time cost telemetry that feeds Runtime's enforcement decisions. When a session approaches its budget ceiling, Runtime does not just alert — it routes to the configured lower tier or halts, depending on the policy.
The 26 policy categories available out of the box include cost-specific controls: per-call token caps, per-session budget hard stops, loop detection with step-count ceilings, and model tier enforcement rules. These apply across the agent fleet without changes to each agent's code. The engineering team in the LeanOps case study spent three weeks implementing equivalent controls manually; a Waxell-instrumented system applies them through initial governance configuration.
The governance plane distinction matters structurally here. An agent that enforces its own cost limits through custom code is only as reliable as that code. A governance layer that sits above the agent and enforces limits regardless of agent behavior is reliable even when agent code changes or new agents are added to the fleet.
The Multi-Agent Budget Problem
Model routing gets significantly more complex when agents spawn sub-agents. A failure mode surfaced in the HN discussion on AgentBudget (May 2026): agent A spawns agent B with its own budget, but B's spend does not count against A's ceiling. B exhausts its budget and stops; A continues, unaware that the total cost has already exceeded the per-task limit.
In pipelines where a single user request triggers a query analysis agent, an embedding agent, a reranking agent, and a response generation agent — each with independent billing — the aggregated cost is invisible to every individual agent. Each one is within its own budget. The total is not.
Runtime's budget hierarchy addresses this through cost propagation: child agent costs roll up to the parent's ceiling, so a task-level budget cap applies to the entire execution tree, not just the triggering agent. This is structural governance, not a post-hoc monitoring aggregate, and it does not require developers to declare the full call graph before runtime.
The Routing Audit Every Team Should Run
Before tooling changes, run this two-step cost audit to establish where current spend actually goes.
Step 1 — Tag every API call with step type (file read, code edit, architectural decision, retry, etc.) and the model used. Aggregate spend by step type and model tier. In most unoptimized systems, this reveals that more than half of spend is on routine operations using a Tier 2 or Tier 3 model.
Step 2 — Map step types to tiers. For the top five step types by cost, determine whether a lower-tier model produces acceptable output. Run benchmark tests per step type with Tier 1 and Tier 2 models against the Tier 3 baseline. In the LeanOps audit data, routine file reads, boilerplate edits, and variable extractions showed no measurable quality difference between Haiku 4.5 and Sonnet 4.6. The quality gap concentrated in architectural reasoning and multi-file debugging with complex dependencies.
Teams that completed this audit and implemented tier routing reduced agent costs by 55–75% within 30 days, according to the LeanOps 30-team study.
FAQ
What is model tier routing for AI agents?
Model tier routing is the practice of directing different agent steps to different model tiers based on cognitive demand. Routine steps like file reads and variable extractions go to cheap, fast models; complex reasoning steps go to frontier models. The goal is to match model cost to the actual reasoning requirement of each step, rather than defaulting every step to the same — usually expensive — model, which is what most agentic frameworks do out of the box.
How much can model tier routing reduce AI agent costs?
According to LeanOps's audit of 30 engineering teams (March–May 2026), routing 80% of agent steps to Haiku-tier models while reserving frontier models for the hard 20% produces 60–80% savings compared to an all-Opus workflow, with comparable output quality. Combined with prompt caching and context pruning, the teams in the audit achieved 55–75% cost reduction within 30 days without measurable quality loss on standard workloads.
Why isn't an observability platform enough to fix this?
Observability platforms like LangSmith and Helicone show you where costs are going after the fact. They do not enforce routing decisions or prevent expensive model calls from happening in the first place. The monitoring gap is not about visibility — it is about enforcement. Model routing policies need to be applied at execution time, before the API call goes out, not surfaced in a post-run cost dashboard.
Does model tier routing affect output quality?
On routine agent steps — file reads, variable extractions, structured data parsing, boilerplate code edits — quality on Haiku 4.5 is equivalent to Sonnet 4.6 for most workloads. The quality difference concentrates in tasks requiring multi-step reasoning over ambiguous, context-dependent inputs: architecture decisions, multi-file refactors with non-obvious dependency chains, security analysis. Routing decisions should be based on empirical quality benchmarks per step type, not intuition.
What is the multi-agent budget inheritance problem?
When agents spawn sub-agents, each sub-agent's costs may not count against the parent's budget ceiling. A task that appears to stay within budget can exceed it because sub-agent spending is not propagated upward. Runtime budget hierarchy, which rolls child costs into parent ceilings, prevents this class of invisible overruns — a problem that does not appear in per-agent dashboards until after the fact.
How does Waxell enforce model routing without requiring code changes?
Waxell Runtime applies routing policies at the governance layer via its instrumentation layer — above agent code. Agents do not implement routing logic internally. The Runtime policy defines which model tiers are permitted for which step types and what cost limits apply per session. These rules apply across the agent fleet through governance configuration, not per-agent rebuilds. No rebuilds required.
Sources
Ravi Kanani, "Agentic AI Cost Runaway: Why One Cursor User Burned $4,200 in a Weekend (And How to Stop It)" — LeanOps, May 14, 2026.
sahiljagtapyc, "Show HN: AgentBudget – Real-time dollar budgets for AI agents" — Hacker News, May 19, 2026.
"Best AI Model for Coding Agents in 2026: A Routing Guide" — Augment Code, 2026.
"LangSmith Pricing" — LangChain, accessed May 2026.
Top comments (0)