Partially fix inherited token accounting across Codex session forks#2113
Partially fix inherited token accounting across Codex session forks#2113iam-brain wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 13, 2026, 12:12 AM ET / 04:12 UTC. Summary Reproducibility: yes. at source level: copied Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the narrow ownership and ancestry correction only if maintainers accept it as an incremental accuracy improvement, while keeping #2037 open for the remaining cumulative-counter discrepancy and additional real-session validation. Do we have a high-confidence way to reproduce the issue? Yes at source level: copied Is this the best way to solve the issue? Yes as a narrow partial correction: canonical filename ownership and fail-open ambiguity handling are safer than speculative global suppression. It is not a complete solution to the linked issue’s remaining cumulative-counter overcount. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c852c135e10c. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Thank you for identifying the inherited-token direction early; this was directionally right and helped frame the later scanner work. This implementation now predates and conflicts with #2118, #2208, and the copied-prefix fix in #2228, so I’m closing it as superseded. If the post-#2228 measurement leaves a specific, reproducible residual, a freshly rebased and narrowly scoped PR for that remaining case would be very welcome. |
Summary
Partially fixes #2037 by improving how the usage scanner resolves parent sessions and subtracts token totals inherited by forked sessions.
Forked rollout files can retain copied
session_metafrom an ancestor, which made metadata-only lookup unreliable and allowed the same inherited usage to be counted repeatedly. This change:Testing against local session data from #2037 reduced the calculated total from roughly 2.23B tokens to 1.24B, compared with approximately 618M reported by OpenAI for the same period. This is still not an exact match, and more work is needed to understand the remaining counter behavior across related and unrelated sessions. However, it closes a substantial part of the gap without introducing speculative family-wide or global suppression that could undercount valid usage.
Testing
swift test --filter CodexSessionFileIndexTests\|Issue2037make testmake checkgit diff --checkAll checks pass.