Skip to content

feat(usage): each share of a run's summary says why it went unpriced and which rates it assumed, with its cache reads and writes - #923

Merged
earakely-scale merged 3 commits into
mainfrom
share-unpriced-reasons
Nov 25, 2026
Merged

earakely-scale merged 3 commits into
mainfrom
share-unpriced-reasons

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

A run's model cost mostly reads unpriced or at least $X with nothing saying why. On the newest 1,347 runs with a ledger on one deployment, 73% read unpriced and 23% at least. The reason is on each ledger entry (unpriced_reason: no_model, no_price or no_tokens), and so are the rates a cost assumed (cost_assumed). But summarize dropped both, so no reader of UsageSummary.to_dict() could explain the figure.

Change

task/usage/summary.py: each Share now keeps, and to_dict now carries:

  • unpriced_reasons: the distinct reasons its unpriced entries or per-model rows gave, sorted; [] when none is unpriced.
  • cost_assumed: the distinct rates its priced parts assumed (cache_read_rate, cache_write_rate, input_excludes_cache), sorted.
  • cache_read_tokens and cache_write_tokens, summed like the input and output counts, null when nothing counted them.

The existing keys and the CLI's cost_line and sources_line don't change. AGENTS.md names the new keys.

Testing

  • summary_test.py: the JSON shape test now pins the four keys. A new test covers reasons and assumed rates gathered from both whole entries and per-model rows, cache counts summed, reasons sorted and distinct, and an unpriced entry that gives no reason.
  • tst/unit/task and tst/unit/cli pass (921), and ruff is clean.
  • On real data: this branch's summarize over the newest 1,347 runs with a ledger on a deployment of the framework, read-only. Every unpriced share names a reason (801 no_price, 838 no_tokens, 1 no_model), every assumed share names its rates, each share's cache reads equal its entries' sums, and every summary round-trips through JSON.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous compatibility issue is fixed.

Summary

Adds cache counts, unpriced reasons, and assumed rates to each share’s JSON.

  • Usage shares now show cache totals, unpriced reasons, and assumed rates.

No new actionable issues found.

Reviews (3) · Last reviewed commit: "fix(usage): a share keeps its assumed fi..." · Reviewed by Greptile

…and which rates it assumed, with its cache reads and writes

A run's cost often reads "unpriced" or "at least" with nothing saying why. The ledger's entries carry the reason
(unpriced_reason: no_model, no_price, no_tokens) and the rates a cost assumed (cost_assumed), but the summary
dropped both, so no reader of its JSON shape could explain the figure. Each share now keeps them, as
unpriced_reasons and cost_assumed, beside its cache reads and writes; to_dict carries all four. The CLI's lines
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 25, 2026 17:06
… and its JSON from its fields

assumed was set from the same entry field as cost_assumed, so the two could drift; it is now a property of
cost_assumed. to_dict builds on asdict, so a new field reaches the JSON without a second list to keep. The JSON
shape is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/task/usage/summary.py Resolved
…rder, as plugins build it

Share is on the plugin surface. The last commit made assumed a read-only property, which a plugin passing
assumed= or setting it would trip over, and the first put the new fields among the earlier ones, which moves
positional arguments. assumed is a field again, set as before, and the four new fields follow partial. to_dict
still builds on asdict, and its JSON is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit 512a41b into main Nov 25, 2026
35 checks passed
@earakely-scale
earakely-scale deleted the share-unpriced-reasons branch November 25, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant