You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pre-turn thread usage snapshots are dropped as "orphan thread-state snapshot with no stored turn/started" #1727
confirmed-reproBug reproduced again from a clean trusted checkout; see linked reportprovider-codexBuilt-in plugin: provider-codexprovidersCross-provider bridges, models, login
On codex resume and on a fork's first turn, the server warns Dropped orphan thread-state snapshot with no stored turn/started for thread/tokenUsage/updated and thread/contextWindowUsage/updated events that arrive before the turn's turn/started is stored, and drops them.
Evidence (final gate run 2, /tmp/final-gate-2.md, pre-existing observation 4, reproduced on origin/main):
Seen on the codex archive→unarchive→resume flow and on the first turn of a forked codex thread. Usage did land for both threads afterwards, so the impact is a transiently missing usage number, not persistent loss.
Question to answer: are pre-turn usage snapshots meant to be dropped, or should they be buffered/attached once the turn row exists? Where to look: apps/server/src/internal/events.ts (~line 949, the drop-with-warning site) and the turn/started persistence ordering for resume/fork first turns.
Surfaced during #1640 final validation; pre-existing (verified on origin/main).
Root cause (short): codex app-server replays the previous turn's token usage on thread/resume and thread/fork; the codex bridge stamps that old Codex turn id with the NEW session's per-session prefix (bt--), so the server sees a turn it never stored turn/started for and (by design) drops the snapshot with a warn log — on resume the payload is an exact duplicate of what is already stored (log noise only), on fork the parent's inherited context usage is discarded until the fork's first turn.
Proposed fix: Keep the server-side orphan drop (it is the correct safety net; buffering would re-create the fork batch-wedging bug). Fix in the codex bridge (plugins/provider-codex/src/bridge/bridge.ts, toCanonicalEvents ~L620): track Codex turn ids this session has emitted turn/started for; for thread/tokenUsage/updated or thread/contextWindowUsage/updated naming any other turn (only resume/fork replays do that), emit the context-window usage thread-scoped ({kind:"thread"} is allowed by the domain scope policy and is what the ACP bridge already does) and drop the token usage (turn-only by policy; duplicate…
Caveats: Not a visual bug, so no screenshots. The worktree was created at a108fa7 (origin/main tip) rather than 16ceb3a; I checked out 16ceb3a before the live runs and rebuilt (relevant files are equivalent between the two). The bridge-level repro test needs a small opt-in extension of the test fixture fake-codex-app-server.mjs (diff included) to mirror the real app-server's usage replay on resume; t…
The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).
confirmed-reproBug reproduced again from a clean trusted checkout; see linked reportprovider-codexBuilt-in plugin: provider-codexprovidersCross-provider bridges, models, login
Activity
SawyerHood commentedon Aug 18, 2026
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1727.html
The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at
16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).Keep replayed Codex usage snapshots out of unknown turn ids
Keep replayed Codex usage snapshots out of unknown turn ids (#1804)