Why realtime model routing can cost more in Claude Code
Prompt caches are kept per model, so switching Claude Code to a cheaper model mid-session starts from a cold cache and re-reads the whole conversation at full price. Sprag delegates to subagents instead and leaves the main session's cache intact.
Not a router — 60 seconds
Sprag installs once, reads the sessions you already run, and does not ask you to change how you prompt. It never intercepts a request or swaps your model in realtime.
- A repeat becomes a rule. The first failure is just work. On the second, Sprag surfaces it as a candidate; you approve the scope, and the rule loads at the start of every session after that.
- Safe work goes to a sub-agent. When a task matches one your history shows is safe, Sprag spawns a sub-agent on a cheaper tier to do it and hands the result back for review. Anything that fails quietly stays with the main agent.
- Cost trouble shows up early. Cache hit rate, TTL expiry, context growth and both rate-limit windows are read every turn and printed in your statusline, while you can still act on them.
Why realtime model routing can cost more, not less
Never switching models mid-session is the point of this design.
Prompt caches are kept per model. Switch to a cheaper model mid-session and it starts from a cold cache, re-reading the whole conversation at full input price. A cache hit costs about a tenth of that, so past roughly 20k tokens of history one switch can erase everything the cheaper model was going to save. You moved the work down a tier and the bill went up: the central paradox of realtime routing.
Teams shipping routing products have turned the feature off for exactly this reason: LLM 라우터를 만든 사람들이 직접 껐습니다 #Shorts (Korean).
So this tool never touches the main session's model. It delegates to subagents only, which leaves the main session's cache intact and runs the delegated work on a cheap model in its own context. That is why the savings are not cancelled out by cache loss.
npm i -g sprag-cli@latest
sprag route-scan # find delegation candidates in your own history (0 LLM calls)
sprag route-scan rules # list promoted rules · rm <N> to remove
sprag route-scan savings # audit every dollar the routing saved
Thresholds come from your own last-14-day distribution (p25/p75), not someone else's benchmark. Measured rule-health — whether a delegated run actually succeeded — landed in v3.9.0.
More docs
- Claude Code statusline: cache hit rate, cache TTL countdown, 5-hour and 7-day rate limits
- Delegate repeat Claude Code work to Haiku and Sonnet subagents with route-scan
- Claude Code harness: ratchet rules, evidence-gated completion, Plan-Execute-Verify
- Convert pptx, xlsx, pdf, docx and fig to Markdown before Claude Code reads them
- Claude Code statusline behind LiteLLM and other gateways
- Install Sprag, the Claude Code token saver
- Sprag command reference
- Korean writing style gate for Claude Code output