Repository navigation
codex daily does not include cache write cost for GPT-5.6 Terra #1617
Description
Activity
github-actions commented
on Aug 20, 2026 on Aug 20, 2026 – with GitHub ActionsContributorMore actionsThis issue was auto-closed. Issues from new contributors are auto-closed by default.
Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.
Keep the issue short, concrete, and written in your own voice.
If a maintainer replies
lgtmi, your future issues will stay open. If a maintainer replieslgtm, your future issues and PRs will stay open.See CONTRIBUTING.md.
pullfrog commented
on Aug 20, 2026 pullfrogboton Aug 20, 2026 – with PullfrogContributorMore actionsAssessment
This issue is actionable and worth reopening for implementation. The report includes a concrete
token_countpayload withcache_write_input_tokens: 57610, a reproducible command, and an expected result. The issue is currently closed by the repository's automatic new-contributor workflow, not because the defect was disproven.The current branch still has the reported gap:
rust/adapters/codex/src/types.rsparses cached reads but has no cache-write field.rust/adapters/codex/src/parser.rsomits cache writes from both direct usage events and cumulative-total subtraction.rust/adapters/codex/src/report.rshard-codescacheCreationTokensto0and does not include cache-write pricing.rust/crates/ccusage-adapter-all/src/loader.rsalso hard-codes Codex cache creation to0for unified reports.- The embedded
gpt-5.6-terrapricing already contains cache-write rates:2.5per million normally and5per million above the model's272000context threshold. The missing work is usage plumbing and Codex billing, not pricing data acquisition.
Issue #1422 documented the same root cause and proposed the broad shape of this fix. Issue #1617 adds confirmation from a newer Codex SDK that the field is now actually present in session logs.
Implementation Plan
- Extend Codex raw usage deserialization to accept
cache_write_input_tokens, with the existing cache-creation spelling as a compatibility alias if appropriate. Add the field toCodexRawUsage, propagate it through direct token events and headless/exec usage, and include it in cumulative-total delta subtraction. Normalize it so cache reads and cache writes form non-overlapping portions of the reported input. - Add cache-creation counters to
CodexTokenUsageEvent,CodexUsageBucket,CodexModelUsage, andCodexGroup. Update long-context tracking, service-tier buckets, group merges, replay handling, and all event deduplication keys so cache-write differences cannot be dropped or double-counted. - Update focused Codex reports so
cacheCreationTokensis populated at group, model, and totals levels, and so plaininputTokensexcludes both cache reads and cache writes. Extend Codex cost calculation with the existing shared cache-write rates, including the model-specific long-context rate and the existing standard/fast service-tier behavior. Use a narrow shared pricing accessor or helper if needed rather than exposing unrelated pricing internals. - Update the unified adapter's
codex_group_rowto expose the same cache-creation and non-cached-input breakdown as focused Codex reports, preserving focused/unified cost parity. - Add regression coverage for the SDK payload shape, the cumulative delta path, overlapping-token normalization, flat cache-write pricing, embedded
gpt-5.6-terrashort and long-context pricing, focused daily JSON, and unified rows. Update affected snapshots and retain coverage proving logs without the new field remain unchanged. - Audit the Codex guide and shared JSON-output documentation. Document that cache writes are reported and priced when the Codex log contains them, while older logs without the field cannot recover that usage. Run the focused adapter tests, unified adapter tests, relevant
ccusagetests, formatting, and the workspace validation prescribed by the repository.
No implementation changes were made during this evaluation.
Task list (3/4 completed)
- Select Plan mode and read required workflow guidance
- Inspect issue discussion, learnings, and Codex pricing/reporting code
- Determine actionability and post an issue plan or analysis
- Report the final outcome
|⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to@v0or keep the SHA fresh with Dependabot | Implement plan ➔ | View workflow run | via Pullfrog | UsingGPT Luna(free via Pullfrog for OSS) | 𝕏- addedminorMerged PR requires a minor version bumpMerged PR requires a minor version bump
on Aug 20, 2026 @pullfrog Triage this issue using the repository standing issue-triage instructions. Inspect the full issue body, comments, current main branch, and related issues or pull requests. Choose exactly one priority label. If the issue is clearly unresolved and is priority:critical or priority:high with safe and well-scoped requirements, implement it and open a focused pull request. Otherwise, only triage it. Keep the explanation short and use simple English.
Reacted by pullfrog- addedpriority:highHigh user impact or an important regression.High user impact or an important regression.
on Aug 27, 2026 pullfrog commented
on Aug 27, 2026 pullfrogboton Aug 27, 2026 – with PullfrogContributorMore actionsPriority: high.
This is a confirmed billing bug on current
main: Codex logs can contain cache-write tokens, but ccusage drops them, socacheCreationTokensandcostUSDare too low. The requirements are clear and the fix is safe and focused. I prepared the fix and tests, but I could not open the PR because pushing the branch failed with:remote: Permission to ccusage/ccusage.git denied to github-actions[bot]. fatal: unable to access 'https://github.com/ccusage/ccusage.git/': The requested URL returned error: 403. PR creation then failed with:Validation Failed: {"resource":"PullRequest","field":"head","code":"invalid"}. |⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to@v0or keep the SHA fresh with Dependabot | View workflow run | via Pullfrog | UsingGPT Luna(free via Pullfrog for OSS) | 𝕏github-actions commented
on Aug 28, 2026 on Aug 28, 2026 – with GitHub ActionsContributorMore actionsPullfrog triage: priority:high
A maintainer explicitly requested an implementation attempt. Confirmed, repository-scoped billing bug: current Codex parsing and reports ignore cache-write tokens, causing GPT-5.6 Terra costs and cacheCreationTokens to be understated. The reproduction, expected behavior, and affected code paths are concrete and safely scoped for a focused fix.
Decision: kept open; Pullfrog will attempt a focused implementation PR.
- addedtriage:resolvedResolved by a later change or current implementation.Resolved by a later change or current implementation.
on Aug 31, 2026 Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.
Audit result: resolved. A later merged change or the current
mainimplementation covers this request. This item is kept for history and does not need to be reopened.

What happened?
This appears to be a follow-up to #1422.
At the time of #1422, Codex CLI did not persist cache-write token usage in rollout
token_countevents. With@openai/[email protected], I can now confirm thatcache_write_input_tokensis present in the session log.However,
[email protected]still reportscacheCreationTokens: 0, so the GPT-5.6 Terra cache-write cost is not included incostUSD.Example Codex SDK log:
{"timestamp":"2026-08-20T05:49:12.034Z","ordinal":177,"type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":935040,"cached_input_tokens":875306,"cache_write_input_tokens":57610,"output_tokens":11150,"reasoning_output_tokens":1141,"total_tokens":946190},"last_token_usage":{"input_tokens":58697,"cached_input_tokens":57817,"cache_write_input_tokens":0,"output_tokens":227,"reasoning_output_tokens":9,"total_tokens":58924},"model_context_window":258400},"rate_limits":null}}For the same session,
ccusage codex daily --jsonreports:{ "cacheCreationTokens": 0, "cacheReadTokens": 875306, "costUSD": 0.42832919999999997, "inputTokens": 59734, "models": { "gpt-5.6-terra": { "cacheCreationTokens": 0, "cacheReadTokens": 875306, "inputTokens": 59734, "outputTokens": 11150, "reasoningOutputTokens": 1141, "totalTokens": 946190 } } }The session contains
cache_write_input_tokens: 57610, but ccusage reportscacheCreationTokens: 0.Since GPT-5.6 Terra charges separately for cache writes, this also causes the reported cost to be underestimated.
Steps to reproduce
@openai/[email protected]with thegpt-5.6-terramodel.cache_write_input_tokensvalue.cacheCreationTokensis0even thoughcache_write_input_tokensis non-zero in the Codex log.Expected behavior
ccusage codex dailyshould readcache_write_input_tokensfrom Codex session logs and include it incacheCreationTokens.The cache write tokens should also be included in the cost calculation using the appropriate cache write pricing for the model.
For the example above,
cacheCreationTokensshould reflect the57610cache write input tokens instead of0.Version
20.0.20