Files
codex/codex-rs/core/tests
Dmitriy Kovalenko 7a030b9769 Fix context token estimates for responses without usable usage (#58404)
## Why

Retained output from failed responses or responses without usage data can be omitted from context token estimates, delaying automatic compaction even as reasoning accumulates.

## What changed

Track the history boundary covered by the last usable usage report and estimate all items added after it. Spending-only updates preserve that boundary, while successful usage reports cover the request input even when the response contains no output items. Avoid counting unreported reasoning twice and align recomputed context counts and remote compaction estimates with the boundary.

## Testing

Add unit coverage for initial input, empty responses, spending-only updates, and reasoning accounting. Add regression coverage verifying that accumulated unreported reasoning triggers compaction for incomplete responses with or without usage and completed responses without usage.

GitOrigin-RevId: 80c0b800c7236ff40ae53fdd18320e0d06e026ab
2026-10-30 18:12:39 +00:00
..