fix(codex): read the human turns Codex writes now, not only the ones it used to - #371
Open
fstubner wants to merge 1 commit into
Open
fix(codex): read the human turns Codex writes now, not only the ones it used to#371fstubner wants to merge 1 commit into
fstubner wants to merge 1 commit into
Conversation
…it used to Codex renamed the shape a user turn arrives in and the reader kept looking for the old one, so every human turn in a current transcript was dropped. The original shape is `event_msg` with `payload.type === "user_message"` and the text on `payload.message`. The current one wraps it: `payload.type === "item_completed"`, `payload.item.type === "UserMessage"`, and the text inside a `content` parts array — the same parts shape the assistant side uses. Nothing caught the change, and nothing could have. `event_msg` is a known event type and `payload.type` was present, so the drift guard had nothing to report; the turns just stopped arriving. Measured across the real store on this machine, 825 session files: 41 turns still in the old shape, 15,169 in the new one, going back to 2025-12. What that produced is worse than a gap. Search still returned the assistant side of every Codex conversation, so a session looked present and complete while carrying almost none of what the person actually asked for — and the question a handoff answers is usually "what was I trying to do", which lives entirely in the half that was missing. Both shapes are read now. `response_item` records with role "user" are still skipped deliberately: they are system-injected context (AGENTS.md, permissions, environment) and they outnumber the real turns in a file carrying both, which is why they were never the answer. Verified against the newest real transcript on this machine: 32 human turns in the file, 0 emitted before, 32 after, text intact. Reverting to the old shape alone turns two of the four tests red. Found by an audit agent reading real Codex files rather than the code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex renamed the shape a user turn arrives in. The reader kept looking for the old one, so every human turn in a current transcript was dropped.
payload.type === "user_message"payload.messagepayload.type === "item_completed",payload.item.type === "UserMessage"item.content[].textNothing caught it, and nothing could have
event_msgis a known event type andpayload.typewas present, so the drift guard had nothing to report. The turns just stopped arriving.Measured across the real store on this machine — 825 session files:
Going back to 2025-12.
Why this is worse than a gap
Search still returned the assistant side of every Codex conversation, so a session looked present and complete while carrying almost none of what the person asked for. The question a handoff answers is usually "what was I trying to do" — which lives entirely in the half that was missing.
Verification
Against the newest real transcript on this machine:
First recovered turn:
"Can you audit this project?"710 tests pass, typecheck and lint clean.
Deliberately unchanged
response_itemrecords with roleuserare still skipped: they're system-injected context (AGENTS.md, permissions, environment) and outnumber the real turns in a file carrying both, which is why they were never the answer.Found by an audit agent reading real Codex files rather than the code.