Skip to content

feat(cost): burn by window for every engine, subagents folded in, Fable 5.1 priced right - #512

Merged
ralyodio merged 1 commit into
mainfrom
feat/cost-burn-windows
Sep 13, 2026
Merged

feat(cost): burn by window for every engine, subagents folded in, Fable 5.1 priced right#512
ralyodio merged 1 commit into
mainfrom
feat/cost-burn-windows

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Closes #511.

What

moshcode cost / usage gets a burn block under the table, the same windows for every engine:

  burn          cost       rate       runs
  last 1 min    $1.32~     $79.16/h   2
  last 15 min   $38.34~    $153.35/h  8
  last 1 hour   $222.03~   $222.03/h  11
  last 4 hours  $966.27~   $241.57/h  19
  last 8 hours  $1786.84~  $223.35/h  45
  window (8h)   $1786.84~  $223.33/h  45
  $3.72 a minute over the window, on average

(real output from the dev box, moshcode cost --all --since 8h). --json carries the rows as burn, each with the cost split by engine. A window longer than --since is left out rather than shown short.

How

  • One exported 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.
  • Codex: a turn is the difference between two running totals. Aider: one sample at the banner. Rows count runs, and a request with no rate counts toward runs and unpriced but never toward cost.

Two bugs the numbers exposed

  • Subagent and workflow transcripts were never read. They live under <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).
  • Fable 5.1 cache reads priced 4x. No claude-fable-5-1 entry, so the prefix match hit claude-fable-5 and derived $1.00/MTok; the published rate is $0.25, on the token class that is ~95% of an agent session. Added claude-fable-5-1 and claude-mythos-5-1 with cacheRead: 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, --json field, table block, alias). Full suite 2992/2992 green in a worktree with pnpm install (the main checkout's node_modules predates the synconfig dependency, so the CLI cannot boot there).

🤖 Generated with Claude Code

https://claude.ai/code/session_0138dZBCdJW73LJjT7kuZf8L

… 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
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

4 finding(s) in the 6 file(s) this pull request changes.

MEDIUM: 4

Severity Rule Location
MEDIUM sql-string-concatenation src/cli-schema.mjs:191
MEDIUM sql-string-concatenation src/cli-schema.mjs:563
MEDIUM sql-string-concatenation src/cli-schema.mjs:596
MEDIUM sql-string-concatenation src/cli-schema.mjs:703
89 pre-existing finding(s) elsewhere in the repository — **HIGH/CRITICAL**: 8 | **MEDIUM**: 71 | **LOW**: 10

Not introduced by this pull request. The full set is in the Security tab.

Severity Rule Location
HIGH js-ssrf-outbound-request apps/pwa/public/sw.js:45
HIGH tls-verification-disabled apps/pwa/src/lib/moshpit-gateway.mjs:299
HIGH sh-remote-script-execution install.sh:86
HIGH sh-remote-script-execution install.sh:90
HIGH sh-remote-script-execution install.sh:258
HIGH sh-remote-script-execution install.sh:269
HIGH sh-remote-script-execution install.sh:275
HIGH tls-verification-disabled src/dns.mjs:766
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:139
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:153
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:179
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:373
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:377
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:422
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:671
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:867
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:869
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:928
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:974
MEDIUM sql-template-interpolation apps/pwa/src/moshpit.mjs:1044

…and 69 more. Full results in the Security tab.

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 13753ee into main Sep 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cost: one standard set of burn windows (1m / 15m / 1h / 4h / 8h / window) across every engine

1 participant