Files
ai-agent/backend/conversations/parse.py
Gabriel Vidal 2408c4dc6f fix(costs): price each API call once, at its exact model version
Claude Code writes an assistant message as one transcript record per
content block, each repeating the call's full usage; the parser summed
them all, so tokens and cost read ~1.93x too high. Calls are now keyed on
(message id, request id), priced once, and the charge is re-homed onto
the tool card the call drove.

pricing.py moves from family prices (every Opus at $5/$25, flat 0.1x
cache reads) to a per-version book (Opus 5.5 $4/$20/$0.20, Fable 5.1
cache reads $0.25, Sonnet 5.x $2/$10, Haiku 5.5 $0.10/$0.50 + its
>100K tier, fast mode 2x), stamped on every summary as priceBook. It also
adds plan_units: what the subscription limits count (each new model
metered at its predecessor's price, Fable x1.75).

Summaries gain planUnits, byModel (per effort), meterBins and fastCalls;
subagents roll them up; project cost splits price per model. PARSER_VERSION
27 re-parses everything: dashboard totals drop to list price (~3.7x lower).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 00:13:54 +02:00

79 KiB