estimate_token_count units bug

Resolved 💬 1 comment Opened Jan 15, 2026 by Zaczero Closed Jan 16, 2026

What version of Codex is running?

0.0.0

What subscription do you have?

N/A

Which model were you using?

_No response_

What platform is your computer?

_No response_

What terminal emulator and version are you using (if applicable)?

_No response_

What issue are you seeing?

estimate_token_count uses estimate_reasoning_length without converting it to token count via approx_tokens_from_byte_count, causing ~4x overcount.

https://github.com/openai/codex/blob/faeb08c1e139590a1e01929d2bf289c2a6c47e2e/codex-rs/core/src/context_manager/history.rs#L100

What steps can reproduce the bug?

when getting back in history, at 25% context usage, the compaction starts as if 100% context was used

What is the expected behavior?

_No response_

Additional information

i think your style of naming is error prone and could be better

or you could make use of strong aliasing

https://doc.rust-lang.org/reference/items/type-aliases.html

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗