Files
codex/codex-rs/core/tests
Tom Wiltzius c82cfe9e53 Defer token count until pending tools finish
The thread metadata rewrite made persisted TokenCount events part of the
observable storage path, which exposed an existing ordering issue in a few
core tests. We were emitting TokenCount as soon as token usage was computed,
even when the turn still had pending tool results or user-input work to
finish.

Split token usage bookkeeping from TokenCount event emission so the session
state can still be updated immediately, while the externally visible
TokenCount event is deferred until the turn is actually complete. This keeps
turn history ordered around tool continuations and avoids recording a token
count before the work it describes has settled.

The test updates in this commit are intentionally separate from the storage
rewrite: they document the corrected event ordering and remove assertions that
were depending on the old premature TokenCount timing.
2026-05-12 09:52:05 -07:00
..