Commit graph

1 commit

Author SHA1 Message Date
Roy Tong
47b7441dd6
fix(codex): preserve distinct requests when cumulative usage is missing (#1264)
* fix(codex): keep token_count events in sessions that never write total_token_usage

* fix(codex): preserve distinct requests when cumulative usage is missing

* fix(codex): narrow missing-cumulative fix - byte-identical re-emissions still collapse (#257)

Real-data answer to the review's question: Codex does re-emit byte-identical
token_count events. Scanned 53 public rollout sessions (codeset-ai/
codeset-release-evals, 1313 token_count events): 603 (46%) are byte-identical
repeats of their predecessor (identical total AND last usage), 0 cumulative
monotonicity violations, 54 events carry no total_token_usage at all.

The missing-cumulative path now collapses a record whose info payload is
byte-identical to the previous event's (#257 semantics restored); only
records with differing payloads count as distinct requests. prevInfoIdentity
is persisted in the resume state. The #1088 invariant note is restored at
the dedupKey in adapted form; docs/providers/codex.md documents the
three-layer dedup and the accepted fork-cutoff trade-off.

* fix(codex): revert cache/parse version bumps, correct null-info docs per review

Re-verified on a fresh spread sample of codeset-release-evals (21 sessions,
404 events): exactly one info:null rate-limit ping per session, zero events
with info present but total_token_usage absent — matching the reviewer's
137k-event corpus. The missing-cumulative branch is a no-op on real data:

- CODEX_CACHE_VERSION stays 15 (no cold reparse for identical numbers; v16
  never shipped in a release)
- drop the -missing-cumulative-v1 parse suffix
- Quirks: null-info pings take the estimate path, not the dedup path; the
  earlier 54-of-1313 figure conflated them with partial-info events
- dedup layer 3 now documents the forkedFromId/#1383 sub-agent caveat

---------

Co-authored-by: Roy tong <tongxiarui@elliwooddeMacBook-Air.local>
2026-09-16 10:50:25 +02:00