Chapter 13 of 14

Watching the Meters

Freddy is nearly done, and so is your provider credit — faster than expected. This chapter is about seeing what agent work costs, routing each turn to the right-sized model, and letting local evidence grade the lineup.

The problem

Model spend is invisible until the invoice, and one-model-for-everything silently overpays: the model that renames a variable shouldn't cost what the model that designs search costs. Back in Chapter 3 you built the manual habit — Ctrl+P down to claude-haiku-4-5 for the small stuff, back up to claude-sonnet-5 for the real work. It's a good habit. It's also a habit, which means you forget it exactly when you're deep in a problem and burning the expensive model on git status questions.

The hard way

Two failure modes, mirror images of each other. Flat-rate everything on the strongest model and eat the bill. Or swing the other way — anxious under-use, running the cheap model on schema design to save cents and paying in rework. Neither is a strategy; both are the absence of a meter.

The Elyra way: read the meter

The meter has been there all along. The footer shows live token stats every turn, and /cost gives the session picture on demand:

/cost

  Session: freddy: archive view
  Input: 412,806 tokens (388,102 cached)
  Output: 31,447 tokens
  Cost: $1.87

Run it early and often until you develop intuition. Most people are surprised in both directions: cached input is cheaper than feared, and long tool-heavy sessions are pricier than they feel.

Smart routing

Now automate the Ctrl+P habit. Enable smartRouting in /settings, and Elyra classifies every turn — fast, balanced, or powerful — and picks a matching model from your lineup. Renames and lookups route to claude-haiku-4-5; ordinary feature work sits in the middle; schema design and tricky debugging go to claude-sonnet-5.

Routing is never silent: every switch appears as a dim line in the chat, so you always know who's talking. Image turns only route to vision-capable models, so the screenshots from Chapter 6 never land on a model that can't see them. And when you want to know what routing would do before committing a prompt, /route previews the decision:

/route

  Next turn would route: fast
  Reason: short, mechanical request; no design decisions
  Picks: fast → anthropic/claude-haiku-4-5
         balanced → openai/gpt-5.6
         powerful → anthropic/claude-sonnet-5

Those per-tier picks are yours to pin via the smartRoutingModels setting if you'd rather choose the lineup than have it inferred.

Budget-aware goals

Chapter 7's /goal loops run until the tests are green — which is wonderful right up until a stubborn failure turns the loop into a money pump. Give it a budget:

/goal composer test --budget 2

The loop now rations itself: past 75% of the budget, routing caps at the balanced tier; past 90%, everything drops to fast. The economics run the right direction — the expensive, design-heavy turns happen early when the budget is full, and the loop tightens its belt as funds run low instead of blowing the last dollar on one heroic powerful-tier turn.

Measured routing: /routing-stats

Routing decisions so far were about the task. The last piece is evidence about the models. Elyra records per-model outcomes locally — turn success, edit failures, retries, failovers away, latency, cost — to a ledger at ~/.elyra/agent/routing-ledger.jsonl. Read it with /routing-stats in a session, or elyra doctor routing outside one:

/routing-stats

  Local model track record (last 30 days):
  - anthropic/claude-sonnet-5: 212 turns, 98% success,
    1.2% edit failures, median 3.1s, $0.041/turn
  - openai/gpt-5.6: 87 turns, 95% success,
    2.8% edit failures, median 4.0s, $0.037/turn
  - anthropic/claude-haiku-4-5: 340 turns, 96% success,
    3.1% edit failures, median 1.1s, $0.004/turn
  - mistral/codestral-2508: 11 turns, 64% success,
    18% edit failures, 4 failovers away
    [demoted in failover ranking]

That last entry is the point: a model with a demonstrably bad local track record gets demoted in cross-provider failover ranking — your own machine's evidence, not a leaderboard's. There's a sample-size floor: fewer than 5 turns never changes anything, so one unlucky afternoon can't blacklist a model.

Privacy: the ledger stores only model ids, counters, and timings — never prompts, never code. Nothing leaves your disk. Opt out entirely with the routingLedger setting.

What you learned

  • /cost early and often. Intuition about spend comes from reading the meter, not from the invoice.
  • Smart routing automates the Ctrl+P habit — per-turn tiers, visible switches, /route to preview, pins via smartRoutingModels.
  • Budgets make /goal loops self-rationing. Expensive turns early, cheap turns late, no money pump.
  • /routing-stats reads like a performance review your models didn't know they were getting — local, private, and with a sample-size floor before anything acts on it.
Next: in Chapter 14 Freddy ships — the final audit, SEO metadata, docs, the deploy pipeline, and the fourteen habits this course was actually about.