Fix "undefined · ~NaNK tokens" in codex compaction boundary - #3379
Fix "undefined · ~NaNK tokens" in codex compaction boundary#3379k11kirky wants to merge 2 commits into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "simplify compact boundary rendering and ..." | Re-trigger Greptile |
|
This PR has had no activity for 7 days and has been marked stale. We are moving to the monorepo and tightening PR staleness in preparation, so it will be closed in 7 days if no further activity occurs. |
The codex-app-server adapter (gpt-5.6-sol and other codex models) emitted the
`_posthog/compact_boundary` notification with only `sessionId`, unlike the Claude
adapter which includes `trigger`, `preTokens`, and `contextSize`. CompactBoundaryView
then rendered `${trigger}` as "undefined" and `Math.round(undefined / 1000)` as NaN,
producing "Conversation compacted · undefined · ~NaNK tokens".
- UsageTracker now retains the model context window (a constant, so it survives
resetForTurn) and exposes contextSize().
- The codex boundary now sends trigger: "auto" (codex only auto-compacts), preTokens
from the live context occupancy, and contextSize.
- CompactBoundaryView and its type chain treat trigger/preTokens as optional and omit
each segment when absent, so a missing value can never render as undefined/NaN again.
Generated-By: PostHog Code
Task-Id: d044b358-be1b-4665-8d32-c28a9ce1badb
Omit preTokens instead of sending 0 when no usage reading exists, reuse formatTokensCompact, and derive one shared detail string for both render branches. Generated-By: PostHog Code Task-Id: 71484330-f52a-49bb-a528-5c708028bbf9
8e9f3bf to
0222420
Compare
|
🤖 CI You Later — rebased this branch onto Conflicts were in 4 files. How each was resolved:
Net effect: the remaining diff vs Verified locally before pushing:
|
|
Closing stale PRs ahead of Friday's monorepo migration. If this is a mistake, rebase and reopen for review. |
Problem
A user on
gpt-5.6-solsaw the transcript render "Conversation compacted · undefined · ~NaNK tokens" after an auto-compaction.The codex-app-server adapter emitted the
_posthog/compact_boundarynotification with onlysessionId, whereas the Claude adapter includestrigger,preTokens, andcontextSize. With those fields missing,CompactBoundaryViewrendered${trigger}as"undefined"andMath.round(undefined / 1000)asNaN.Changes
UsageTrackerretains the model context window and exposescontextSize().trigger: "auto"(codex only auto-compacts),preTokensfrom live context occupancy, andcontextSize.CompactBoundaryView(and its type chain) treattrigger/preTokensas optional and omit each segment when absent — so a missing value can never render asundefined/NaNagain.Why
Reported by a user; the compaction marker was showing garbage text on codex models.
How did you test this?
trigger: "auto",preTokens: 185000,contextSize: 200000. All 75 codex agent tests pass.pnpm --filter @posthog/ui typecheckand@posthog/agentbuild pass; Biome lint clean on the changed files.Automatic notifications
Created with PostHog Code