The Economics of an LLM Agent: 32 Days of Telemetry, Two Configurations, One SQL Bug
TL;DR
- Over 32 days of detailed telemetry (~4,300 runs), the agent’s burn fell from $61 to $18 per day: the main loop moved from claude-fable-5-1 to glm-5.3-flash, and the strong model stayed on as a consultant.
- Counterfactual at identical token volumes: the same GLM workload on Fable 5.1 would have cost $1,521 against $109 in fact (−93%); on Opus 5.5 — $748 (−85%).
- The bill is driven not by volume but by rare events: 94% of prompt tokens are cache reads costing cents, while 53% of the Fable bill is cache writes at $12.50/MTok.
- The consultant came to 152 calls, 13.6M prompt tokens, and $146 — 10% of the period’s budget.
- The first calculation overestimated the Claude-era cost by 37% because of double-counted cache writes; the error is dissected in a dedicated section.
Configuration
Atlas is a desktop agent: a Go service with local SQLite and the usual agent loop of model plus tools. It reads and edits files, runs commands, works with git, queries LSP and databases, and delegates tasks to subagents. It has been part of my daily workflow for a long time, and so has its spend telemetry — every completed LLM run writes a row to the local DB with the model and four token counters. On September 20 the subagents got per-run counters; on September 28 every role got them, and the rows acquired a spend source. From that day the tracking is per-line by role:
| Source | Role | Model |
|---|---|---|
main | main loop | user’s choice: fable-5.1 → glm-5.3-flash |
subagent | delegated tasks | glm-5.3-flash |
review | commit review | glm-5.3-flash |
consultant | strong model on demand | fable-5.1 / opus-5 (logged as help) |
Over the telemetry window the agent went through two configurations differing in a single decision: who runs the main loop.
The first, until October 15: main on claude-fable-5-1 / claude-opus-5-5, with subagents and review on glm-5.3-flash. Every turn of the main loop was a turn of the flagship, including the trivial ones. (In the first week, before full tracking, subagents also ran on claude-sonnet-5, claude-opus-5, and GLM-5.3 before moving to flash.)
The second, from October 16: main on glm-5.3-flash. Fable 5.1 and Opus 5 are invoked only as consultant, in three cases: the main agent has rejected its own hypothesis twice; the same check keeps failing after edits; or a design decision is coming up — a DB schema, a public API, a plan decomposition. The consultant sees only the formulated question and the evidence attached to it: the error, the diff, the schema.
This is a split of roles, not a tariff change. The workload stays on the model that costs $0.15/MTok of input; the strong model’s intelligence is bought in ~90K-token portions, only where the cheap model has exhausted its own options. Now the numbers for both configurations.
Data and formula
Every usage_events row carries a source, a model, and four counters: prompt, completion, cache_read, cache_write. The cost of a row:
(p − cr − cw)·input_price + cr·cache_read_price + cw·cache_write_price + c·output_price
where p is prompt_tokens, c is completion, cr is cache_read, cw is cache_write, all divided by 1e6. One detail matters: the provider’s prompt_tokens is an aggregate that already includes cache_read and cache_write, so both are subtracted. The postmortem section covers what happens when you don’t.
List prices, $ per 1M tokens:
| Model | Input | Output | Cache read | Cache write |
|---|---|---|---|---|
| claude-fable-5-1 | 10 | 50 | 0.25 | 12.50 |
| claude-opus-5-5 | 4 | 20 | 0.20 | 5.00 |
| claude-opus-5 | 5 | 25 | 0.50 | 6.25 |
| claude-sonnet-5 | 2 | 10 | 0.20 | 2.50 |
| GLM-5.3 | 1.40 | 4.40 | 0.26 | no separate rate |
| glm-5.3-flash | 0.15 | 0.50 | 0.03 | no separate rate |
The first row is the key one: the Anthropic flagship’s cache write costs $12.50/MTok — 125% of its own input rate and 417× the cache-read rate of glm-5.3-flash. Practically the entire economics gap between the two configurations follows from this row.
The observation window is Sep 20 – Oct 21. In the first week (Sep 20–27) main and review were not logged anywhere; subagent spend was reconstructed by a migration from the subagents table: 218 runs, 642M prompt tokens, $325. Per-line tracking across all roles starts September 28. For the period: ~4,300 runs, $1,529.
Two configurations
| Claude (Sep 28 – Oct 15, 18 days) | GLM (Oct 16–21, 6 days) | |
|---|---|---|
| main | fable-5.1 / opus-5.5 | glm-5.3-flash |
| Consultant | fable-5.1 / opus-5 | fable-5.1 / opus-5 |
Prompt tokens (per usage_events, from Sep 28) | 5.04B | 1.47B |
| Spend | $1,095 | $109 |
| Price per MTok of prompt | $0.217 | $0.074 |
| Rate | ≈$61/day (≈$1,830/mo) | ≈$18/day (≈$550/mo) |
Daily spend, dollars:
| Sep 20: 12.7 | Sep 21: 65.8 | Sep 22: 18.7 | Sep 23: 109.3 | Sep 24: 15.3 | Sep 25: 39.8 | Sep 26: 3.1 | Sep 27: 60.6 |
| Sep 28: 136.6 | Sep 29: 53.6 | Sep 30: 64.4 | Oct 1: 103.2 | Oct 2: 118.6 | Oct 3: 37.9 | Oct 4: 9.0 | Oct 5: 49.4 |
| Oct 6: 87.8 | Oct 7: 57.3 | Oct 8: 66.6 | Oct 9: 24.6 | Oct 10: 21.1 | Oct 11: 44.9 | Oct 12: 80.9 | Oct 13: 68.3 |
| Oct 14: 44.2 | Oct 15: 26.5 | Oct 16: 23.7 | Oct 17: 22.0 | Oct 18: 18.4 | Oct 19: 14.9 | Oct 20: 14.6 | Oct 21: 15.7 |
Until October 15 the daily burn swings between $9 and $137; after, it holds in the $15–24 band. The default_model_id change is recorded in settings on October 17; the series breaks on the 16th.
Comparing configurations on absolute numbers is weak: the periods differ and the workload changed. The main conclusions rest on a counterfactual with token volumes held fixed.
Counterfactual
The actual token volumes of every run are priced at a single model’s rates, as if all traffic went through it:
| Scenario | Sep 20 – Oct 21 | Savings |
|---|---|---|
| Actual (mixed stack) | $1,529 | — |
| All on Fable 5.1 (fresh input at the input rate) | $6,916 | −78% |
| All on Fable 5.1 (fresh input billed as cache write, 1.25×) | $7,691 | −80% |
| All on Opus 5.5 | $3,298 | −54% |
The most reliable numbers come from the GLM configuration, where volumes were fixed with the scheme unchanged: the same workload on Fable 5.1 would have cost $1,521 against $109 in fact — minus 93%. On Opus 5.5 — $748, minus 85%. These figures do not depend on how the workload shifted between configurations.
The counterfactual assumes token volumes stay the same; on a different model, sessions may behave differently — different context lengths, different turn counts. The order of magnitude of the effect is not explained by this: glm-5.3-flash in the main role consumes the same order of tokens as the subagents of the Claude configuration did.
Bill anatomy
The intuition “you pay for volume” does not survive the data. 94% of the period’s prompt tokens are cache reads. glm-5.3-flash pushed 6.4B prompt tokens over the period (including the first-week backfill), 6.1B of them cache reads at $0.03/MTok, and its entire bill is $245.
The Fable 5.1 bill for the period, broken down by tariff component:
| Component | Tokens | Money | Share |
|---|---|---|---|
| Cache write ($12.50/MTok) | 33M | $417.6 | 53% |
| Output ($50/MTok) | 2.8M | $137.5 | 17% |
| Fresh input ($10/MTok) | 17M | $165.2 | 21% |
| Cache read ($0.25/MTok) | 284M | $71.0 | 9% |
| Total | $791.3 |
53% of the flagship’s bill is cache writes — more than all other components combined. The mechanics: every “cold” context the agent assembles from scratch is billed at 1.25× the input rate. Moving main to glm-5.3-flash removed this line entirely: Z.AI has no separate cache-write rate, and it has been zero in telemetry since October 16.
Spend by model over the period:
| Model | Spend | Role |
|---|---|---|
| claude-fable-5-1 | $791 | main of the Claude configuration + consultant |
| glm-5.3-flash | $245 | subagents, review, main from Oct 16 |
| claude-opus-5 | $211 | consultant + first-week subagents |
| claude-opus-5-5 | $150 | main of the Claude configuration |
| claude-sonnet-5 | $86 | first-week subagents |
| GLM-5.3 | $46 | subagents before the move to flash |
In the Claude window (Sep 28 – Oct 15), Anthropic accounted for 11% of prompt tokens and 81% of the money.
The consultant
The routine work goes to glm-5.3-flash: files, search, edits, tests, diff review. The strong model joins on three triggers: the main agent has rejected its own hypothesis twice; the same check keeps failing after edits; or a design decision is coming up — a DB schema, a public API, a plan decomposition. The consultant receives only the question and the evidence: the error, the diff, the schema.
Over the period: 152 calls, 13.6M prompt tokens, $146 — about 10% of the budget. In the GLM configuration the consultant costs $7.4 per day out of $18.2 total — 41%, comparable to all the agent’s other work combined. Moving the same workload entirely to Fable would have cost $1,521 against $109 — 14 times more.
There is no quality metric for decisions, so the “value” of consultations is not being priced in dollars. The measurable fact: 10% of the budget on the strong model. The observed consequence for day-to-day work: delegating tasks to subagents stopped being a decision about manageable costs, and the strong model stopped being a bottleneck in the main loop.
Postmortem: the costing bug
The first calculation gave the Claude era $1,502 and September 28 $190.27. Both figures went into the draft overstated: the era by 37% (1,502 vs 1,095), the day by 39% (190.27 vs 136.59).
The provider’s prompt_tokens is an aggregate that includes cache_read and cache_write. The correct formula subtracts both:
(p − cr − cw)·input + cr·cache_read + cw·cache_write + c·output
The first calculation subtracted only cache_read: (p − cr)·input + ... + cw·cache_write. Cache-write tokens were billed twice — at $10 as fresh input and at $12.50 as cache write. The error did not show on the GLM configuration: Z.AI reports no separate cache writes, so the term is zero. The bug lived in one branch of the data and was invisible in the “new” numbers.
Localization. The era total ($1,502) did not match the sum of daily figures under the correct formula ($1,095) and did match the sum under the wrong one ($1,501 — within rounding of the daily values from the draft’s $1,502). The decisive check sat at the boundary between sources: September 23, computed from the subagents backfill, matched the correct formula to the cent (109.28); September 28, from usage_events, matched only the wrong one (190.27). The asymmetry pointed at the data branch, not at the tariffs. Under the correct formula: Sep 28 — $136.59, the era — $1,095, the period — $1,529.
The same check exposed a second error: token volumes were computed by adding cache_read on top of prompt_tokens — 9.89B instead of 5.04B for the era. Any “price per MTok” derived from such volumes is understated by half.
For anyone building per-line accounting, this yields two rules: store the components (fresh input, cache_read, cache_write, output) separately rather than as the provider’s single aggregate; and reconcile the aggregate total against the sum of daily figures before publishing. Both checks localized the error within minutes here.
Limitations
- Prices are list prices. Traffic through an aggregator (OpenRouter and similar) adds a markup. Z.AI’s promotional rates (valid until Sep 9) were not applied.
- The counterfactual rests on unchanged token volumes — see above.
- There was no per-line tracking by source before Sep 20; from Sep 20–27 main and review were not logged, and the
usage_eventstable did not exist yet — that week’s subagent runs are stored line by line with full counters in thesubagentstable and were carried over by a migration. The conclusions cover the period of full tracking. - Z.AI’s cache writes may be billed inside the input rate — in which case the real GLM spend is higher than calculated. The $0.15-vs-$12.50-per-MTok ratio leaves the order of the effect unchanged.
- The configuration comparison is not a controlled experiment: the workload changed along with the scheme.
- Anthropic cache writes come in 5-minute and 1-hour flavors (the latter at 2× the rate); the telemetry does not distinguish them, so $417.6 for cache writes is a lower bound.
- ~205 subagent runs after Sep 28 are recorded in
subagentsbut missing fromusage_events; the undercount is a few dollars and shifts the actual and counterfactual figures by roughly the same amount.
Takeaways
- Per-line tracking gives what a provider’s billing counter cannot: a 4,300-row table broke the bill down by component and by role and localized a bug in my own costing formula.
- Cache is a separate economy, not the “cheap part of the bill.” Cache reads are nearly free at 94% of volume; cache writes at flagships are the largest line item. Agent architecture should minimize cold contexts: reuse the system prompt, avoid reassembling context, keep long sessions on one model.
- Routing by complexity is the next step in an agent’s evolution and the biggest lever in its economics: the cheap model gets the volume, the strong model is invoked by triggers. Minus 85–93% on the same work is the result of changing the scheme, not picking a tariff.
- The consultant is cheap because its context is small: 13.6M tokens over 152 calls — about 90K each. A strong model’s cost scales with context; a narrow context is how you buy intelligence in bulk.
- The scheme scales down in price: as long as the routine stays on the cheap model, the headroom after the switch leaves room to experiment with routing — another subagent, another provider — without recalculating the economics every time.
Telemetry keeps running. By mid-January there will be three months of the pure GLM scheme — enough to see the spend trend across task types, compare against previous months, and watch quality over distance. I’ll write that up separately.