Skip to content

Avoid cloning thread history for token usage replay - #34361

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/69c4a9fe04770d1a938470afc933431e61670094
Jul 20, 2026
Merged

Avoid cloning thread history for token usage replay#34361
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/69c4a9fe04770d1a938470afc933431e61670094

Conversation

@copyberry

@copyberry copyberry Bot commented Jul 20, 2026

Copy link
Copy Markdown

Avoid cloning thread history for token usage replay

What changed

  • Resolve the turn ID for restored token usage before sending resume and fork responses, avoiding a clone of the full thread history.
  • Add ThreadHistoryBuilder::active_turn_id so attribution can inspect the active turn without materializing its items.
  • Stop history reconstruction at the latest persisted TokenCount and verify that a later tail turn does not receive the replayed usage.

## What changed

- Resolve the turn ID for restored token usage before sending resume and fork responses, avoiding a clone of the full thread history.
- Add `ThreadHistoryBuilder::active_turn_id` so attribution can inspect the active turn without materializing its items.
- Stop history reconstruction at the latest persisted `TokenCount` and verify that a later tail turn does not receive the replayed usage.

GitOrigin-RevId: 69c4a9fe04770d1a938470afc933431e61670094
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/69c4a9fe04770d1a938470afc933431e61670094 branch from 8cc6e86 to 1e20272 Compare July 20, 2026 14:53
@copyberry
copyberry Bot merged commit 1e20272 into main Jul 20, 2026
31 of 32 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/69c4a9fe04770d1a938470afc933431e61670094 branch July 20, 2026 14:55
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants