Why Model Routing Backfires and How to Build Agents That Don’t Burn Your Budget
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
Model routing can reduce AI inference costs by 40–85%, but switching models mid-session in agentic workflows destroys prompt cache savings, often costing more than no routing at all. Each provider's KV cache is model-specific, so a mid-session switch forces the new model to reprocess the entire conversation history at full input token rates. Common anti-patterns include enabling auto-routing mid-session via gateways like LiteLLM or OpenRouter, modifying tools or system prompts during a session, and using a separate model for history compression. Better approaches include keeping sessions short, using an orchestrator-subagent architecture where each subagent starts fresh with only the context it needs, locking session configuration at start, and summarizing state explicitly before any unavoidable model switch. The post also promotes JFrog Boost, a CLI tool that compacts terminal output to reduce context bloat in agentic coding loops.