Skip to content

fix(codex): preserve distinct requests when cumulative usage is missing - #1264

Open
roy-tong wants to merge 2 commits into
getagentseal:mainfrom
roy-tong:fix/codex-no-total-events
Open

fix(codex): preserve distinct requests when cumulative usage is missing#1264
roy-tong wants to merge 2 commits into
getagentseal:mainfrom
roy-tong:fix/codex-no-total-events

Conversation

@roy-tong

@roy-tong roy-tong commented Sep 6, 2026

Copy link
Copy Markdown

When total_token_usage is absent, the old cumulative guard and all-zero deduplication key collapse subsequent requests. Keying only on last usage also loses distinct requests with equal token amounts.

This revision:

  • applies the cumulative guard only to a finite, nonnegative reported total_tokens;
  • treats absent, null and partial totals as missing identity rather than zero;
  • uses source path and physical record offset for fallback identity, preserving distinct equal-usage rows and stable same-file rereads;
  • deliberately makes no cross-file replay-deduplication claim when cumulative identity is unavailable;
  • invalidates both Codex result and provider/session caches so existing aggregates are reparsed.

Validation: 37 tests pass across the relevant Codex test files, including the new three-case regression and cache invalidation coverage; TypeScript --noEmit passes. The three missing-cumulative regressions fail on the previous PR head and pass with this revision. Fixtures are synthetic.

@roy-tong roy-tong changed the title fix(codex): keep token_count events in sessions that never write total_token_usage fix(codex): preserve distinct requests when cumulative usage is missing Sep 7, 2026
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.

1 participant