Skip to content

Skip unchanged native Codex token snapshots - #10531

Open
Brams-s wants to merge 1 commit into
omacom:quattrofrom
Brams-s:fix/codex-repeated-token-count
Open

Skip unchanged native Codex token snapshots#10531
Brams-s wants to merge 1 commit into
omacom:quattrofrom
Brams-s:fix/codex-repeated-token-count

Conversation

@Brams-s

@Brams-s Brams-s commented Sep 6, 2026

Copy link
Copy Markdown

Native Codex can emit another token_count notification when quota information changes while retaining the previous request's last_token_usage and total_token_usage. The collector adds that request again: a 100-input/10-output request followed by an unchanged usage notification currently produces 220 tokens and two prompts instead of 110 tokens and one prompt.

Track the last counted cumulative snapshot within each rollout and skip unchanged snapshots. Requests with equal token counts still count when cumulative usage advances; changed/reset counters and records without cumulative counters retain their existing behavior. Cache schema version 2 invalidates totals generated before this correction, including on --limits-only refreshes.

This is limited to repeated native notifications. Pi inherited-message handling remains in #8602; its patch applies cleanly alongside this change. The model-aware hourly view discussed in #9204 remains a separate follow-up to #8862.

Validation:

  • New native-notification regression suite: 6 cases pass; the repeated-notification case fails on the unchanged base (330 tokens instead of 110).
  • Existing Codex scanner suite passes, including repeated quota notifications, prompt counts, cache/reasoning accounting, and invalidation of a fresh version-1 cache.
  • Python syntax and git diff --check pass.
  • ./test/all: CLI suite passes; 226/228 shell test files pass. The two failures reproduce on an untouched checkout of base a62e34ea: bin-style-test.sh flags existing raw command checks in omarchy-remove-ai-hermes / omarchy-remove-ai-openclaw; launch-about-test.sh fails “a roomy window animates.”

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