You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Observed behavior
For Codex token_count events, the session telemetry includes:
input_tokens
cached_input_tokens
cache_write_input_tokens
output_tokens
reasoning_output_tokens
The parser currently:
derives uncached input as input_tokens - cached_input_tokens;
ignores cache_write_input_tokens and passes zero cache-creation tokens to pricing;
prices output_tokens + reasoning_output_tokens;
uses one static model-rate record, without selecting OpenAI short- versus long-context prices per call.
Why this is inaccurate
Cache-write tokens are a subset of uncached input, not an additional fifth token category. They must be split out of uncached input and charged at OpenAI’s cache-write rate—without double-counting their volume.
In Codex telemetry, reasoning output appears to be included in output_tokens: e.g. 23,318 input + 251 output = 23,569 total, while reasoning output is 53. Adding reasoning to output therefore double-bills those tokens.
OpenAI’s model pricing has different short- and long-context matrices. The parser already has each call’s input volume, but Codeburn applies a single LiteLLM rate. Long-context calls can consequently be materially underpriced.
Concrete test session
59 calls, all gpt-5.6-terra
7,748,962 input tokens total
7,568,256 cached input tokens
180,706 uncached input tokens
180,430 cache-write input tokens
27,027 output tokens
10,098 reasoning-output tokens
44 calls had input totals of at least 128k tokens; maximum was 180,433
Suggested correction
Read cache_write_input_tokens.
Clamp it to uncached input, charge that portion at the cache-write rate, and charge only the remainder at the standard input rate.
Treat reasoning_output_tokens as an output breakdown for Codex unless the source explicitly establishes it is exclusive.
Add model-specific short/long-context threshold handling rather than a single static price record.
Thanks for the detailed report and the concrete session numbers — they made this verifiable. I ran all three claims against a large real corpus (1,396 rollout files, 136,094 token_count events, 45,638 priced calls) plus OpenAI's published docs. Verdicts:
Claim 2 — reasoning double-count: confirmed, fixing now
You're right, and the evidence is unambiguous. Of 134,316 events carrying a total, all 134,316 satisfy input + output == total; zero satisfy the exclusive reading. OpenAI's reasoning guide says the same: reasoning tokens are billed as part of output. CodeBurn adds reasoningOutputTokens on top in the decoder (src/providers/codex.ts), in the cache-rehydration path (src/parser.ts — which already special-cases claude for exactly this reason; codex just wasn't on the list), and in three display sums. On this corpus that's a +3.5% cost overstatement and +34.6% inflated Output tokens. Your session reprices $2.32 → $2.20.
Claim 1 — cache_write_input_tokens: confirmed as a gap, guarded fix incoming
The field is never read and cacheCreationInputTokens is hardcoded to 0 — real. Two nuances from verification:
The field is brand new (codex PR #33454); in this corpus it appears in only 75 of 135,409 events (one CLI alpha, one day) and is zero in all of them — so present-day impact here is $0.
The cache-write surcharge only exists for gpt-5.6+ (1.25× input; e.g. terra $2.00/$2.50/M). Pre-5.6 models have no cache-write fee, and CodeBurn's buildCostsfabricates a 1.25× rate when the source omits one — so the fix must charge the cache-write rate only when the pricing source carries it explicitly, or it would invent a surcharge on older models. Implemented that way, with the clamp to uncached input you suggested (your own session: +$0.09).
Claim 3 — long-context tiers: real gap, but the threshold is 272k, not 128k — deferring
OpenAI's short/long-context split for these models sits at 272,000 input tokens ("Short context ≤272K"), and LiteLLM's tier fields agree (*_above_272k_tokens, on 5.4/5.5/5.6 only). Every one of your 44 cited calls (max 180,433) is below the real threshold, so none of them was mispriced by the missing tiers. Measured on this corpus at the correct threshold: 8 of 45,638 calls affected, +$1.28 (+0.03%). At 128k as filed it would have repriced 53% of all calls and fabricated +64% spend. Given the cost of threading a tier dimension through the whole pricing model for +0.03%, I'm deferring this to a separate tracked issue (at 272k, provider-generic) rather than bundling it here.
Bonus finding from the sweep
gpt-5.6-codex and gpt-5.6-codex-max are missing from the bundled snapshot entirely — 5,446 calls in this corpus price at $0.00. Tracked separately.
PR for claims 2 + 1 (with the codex results-cache and daily-cache version bumps a cost change requires) is on its way and will link back here.
Activity
iamtoruk commentedon Aug 21, 2026
Thanks for the detailed report and the concrete session numbers — they made this verifiable. I ran all three claims against a large real corpus (1,396 rollout files, 136,094
token_countevents, 45,638 priced calls) plus OpenAI's published docs. Verdicts:Claim 2 — reasoning double-count: confirmed, fixing now
You're right, and the evidence is unambiguous. Of 134,316 events carrying a total, all 134,316 satisfy
input + output == total; zero satisfy the exclusive reading. OpenAI's reasoning guide says the same: reasoning tokens are billed as part of output. CodeBurn addsreasoningOutputTokenson top in the decoder (src/providers/codex.ts), in the cache-rehydration path (src/parser.ts— which already special-cases claude for exactly this reason; codex just wasn't on the list), and in three display sums. On this corpus that's a +3.5% cost overstatement and +34.6% inflated Output tokens. Your session reprices $2.32 → $2.20.Claim 1 —
cache_write_input_tokens: confirmed as a gap, guarded fix incomingThe field is never read and
cacheCreationInputTokensis hardcoded to 0 — real. Two nuances from verification:buildCostsfabricates a 1.25× rate when the source omits one — so the fix must charge the cache-write rate only when the pricing source carries it explicitly, or it would invent a surcharge on older models. Implemented that way, with the clamp to uncached input you suggested (your own session: +$0.09).Claim 3 — long-context tiers: real gap, but the threshold is 272k, not 128k — deferring
OpenAI's short/long-context split for these models sits at 272,000 input tokens ("Short context ≤272K"), and LiteLLM's tier fields agree (
*_above_272k_tokens, on 5.4/5.5/5.6 only). Every one of your 44 cited calls (max 180,433) is below the real threshold, so none of them was mispriced by the missing tiers. Measured on this corpus at the correct threshold: 8 of 45,638 calls affected, +$1.28 (+0.03%). At 128k as filed it would have repriced 53% of all calls and fabricated +64% spend. Given the cost of threading a tier dimension through the whole pricing model for +0.03%, I'm deferring this to a separate tracked issue (at 272k, provider-generic) rather than bundling it here.Bonus finding from the sweep
gpt-5.6-codexandgpt-5.6-codex-maxare missing from the bundled snapshot entirely — 5,446 calls in this corpus price at $0.00. Tracked separately.PR for claims 2 + 1 (with the codex results-cache and daily-cache version bumps a cost change requires) is on its way and will link back here.
fix(codex): stop double-billing reasoning output, price cache writes …
docs(pricing): bound the codex repricing drift in verify:upgrade, fix…
Merge origin/main into feat/copilot-session-store
fix(pricing): carry long-context tier rates through bundling and pric…
fix(pricing): carry long-context tier rates through bundling and pric…
fix(pricing): carry long-context tier rates through bundling and pric…
fix(pricing): carry long-context tier rates through bundling, applied…