feat(cost): burn by window for every engine, subagents folded in, Fable 5.1 priced right - #512
Merged
Merged
Conversation
… in; price Fable 5.1 right
`moshcode cost` answered "what did today cost". It now also answers "how fast
is it going", with one set of windows for every engine: under the table, a
`burn` block shows the last 1 min, 15 min, 1 hour, 4 hours, 8 hours and the
report window, each with what the requests inside it cost, that cost per hour
of window, and the runs behind it; `--json` carries the rows as `burn`, with
the cost split by engine. Every reader now keeps its requests as samples
(`{ at, usage, model, engineCost }`) in the shared usage shape, so bucketing is
one function over all engines. Codex logs running totals, so a turn is the
difference between two; aider stamps only its banner, so a run lands there.
Two things the numbers exposed on the way:
- Claude Code writes a session's subagent transcripts under
`<session>/subagents/` (workflow agents one level deeper), all carrying the
parent's sessionId. The reader stopped at the top of the project directory
and never saw them — on a box running workflows, about a quarter of the
bill. They now fold into the parent's run, deduped by message id across the
session because the parent replays a subagent's messages.
- The rate card had no `claude-fable-5-1` entry, so the prefix match landed on
`claude-fable-5` and priced cache reads at $1.00/MTok. Fable 5.1 reads the
cache at $0.25, and on an agent session cache reads are most of the tokens.
`claude-fable-5-1` and `claude-mythos-5-1` now carry `cacheRead: 0.25`.
Closes #511.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138dZBCdJW73LJjT7kuZf8L
ThreatCrush Security Scan4 finding(s) in the 6 file(s) this pull request changes. MEDIUM: 4
89 pre-existing finding(s) elsewhere in the repository — **HIGH/CRITICAL**: 8 | **MEDIUM**: 71 | **LOW**: 10Not introduced by this pull request. The full set is in the Security tab.
…and 69 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #511.
What
moshcode cost/usagegets aburnblock under the table, the same windows for every engine:(real output from the dev box,
moshcode cost --all --since 8h).--jsoncarries the rows asburn, each with the cost split by engine. A window longer than--sinceis left out rather than shown short.How
BURN_WINDOWS; every reader emits per-request samples{ at, usage, model, engineCost }in the shared usage shape;burn(runs, { since })buckets and prices them once for all engines. Engine-priced requests (opencode, aider) keep their own number;~still means estimated.unpricedbut never toward cost.Two bugs the numbers exposed
<session>/subagents/…carrying the parent's sessionId; the reader stopped at the top of the project directory. On this box that was ~25% of the spend. They now fold into the parent's run, deduped by message id across the session (the parent replays a subagent's messages).claude-fable-5-1entry, so the prefix match hitclaude-fable-5and derived $1.00/MTok; the published rate is $0.25, on the token class that is ~95% of an agent session. Addedclaude-fable-5-1andclaude-mythos-5-1withcacheRead: 0.25.Tests
test/cost.test.mjs: 63/63 (burn bucketing, per-hour maths, mixed sources, unpriced, the 5.1 rate, claude samples, subagent folding with replay dedupe, codex deltas,--jsonfield, table block, alias). Full suite 2992/2992 green in a worktree withpnpm install(the main checkout'snode_modulespredates the synconfig dependency, so the CLI cannot boot there).🤖 Generated with Claude Code
https://claude.ai/code/session_0138dZBCdJW73LJjT7kuZf8L