fix(codex): stop merging multi-turn assistant replies into one message - #15
Merged
Conversation
Codex sessions where the model replied multiple times before the next user prompt (or task_complete) collapsed all those replies into a single assistant message. That pushed messageCount down to 2, which tripped the "trivial session" filter in sync and silently dropped otherwise substantial sessions from the database. Flush the accumulated assistant turn whenever a new assistant text block starts, so each reply becomes its own message. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ClaudiaFang
marked this pull request as ready for review
July 21, 2026 12:39
ClaudiaFang
pushed a commit
that referenced
this pull request
Jul 23, 2026
feat: capture thinking content, tool results, and per-message usage
ClaudiaFang
added a commit
that referenced
this pull request
Jul 23, 2026
fix(codex): stop merging multi-turn assistant replies into one message
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.
Summary
task_complete) were being merged into a single assistant message, sinceflushAssistantTurn()only triggered on a new user message or turn completion.messageCount === 2, which trips the "trivial session (≤2 messages)" skip filter insync.ts— the session was parsed correctly but silently never written to the DB.Fix
cli/src/providers/codex.ts: flush the in-progress assistant turn whenever a newresponse_item/message(role=assistant) block starts, instead of only onuser_message/task_complete. Eachoutput_textblock from Codex is a full reply, not a streaming delta, so this correctly produces one message per assistant turn.Session boundaries are unaffected — one rollout file is still one session; this only changes how messages within a session are split.
Test plan
pnpm build(tsc) passespnpm test— all 902 existing tests pass, includingcodex.test.tscode-insights sync --source codex-cli --forcelocally — both previously-missing 2026-07-21 sessions now appear in the DB (today's codex-cli count: 9 → 11)