mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
## Why A model can change between steps of the same turn. Persisted token usage records need the model for each response to distinguish usage before and after the switch. ## What changed Add an optional `model` field to `TokenUsageRecord`. Record the model selected for the sampling step on both completed and incomplete responses. Attribute compaction usage to the model selected at the start of the turn. Existing records without the field still deserialize. ## Testing Extend coverage to check persisted model attribution and cumulative token totals after a mid-turn switch, including when the response hits the output token limit. Verify that compaction keeps the turn-start model attribution and continues restored usage totals. GitOrigin-RevId: 3615724c1cbe6ed46c9367d6c3c1a29ebaba73d8