Skip to content

Show which model Codex sessions use#189

Merged
wesm merged 2 commits intowesm:mainfrom
clkao:codex-model-parsing
Mar 19, 2026
Merged

Show which model Codex sessions use#189
wesm merged 2 commits intowesm:mainfrom
clkao:codex-model-parsing

Conversation

@clkao
Copy link
Copy Markdown
Contributor

@clkao clkao commented Mar 19, 2026

Summary

  • Codex sessions now display the model name (e.g. gpt-5-codex, o3-pro) alongside each message, matching what Gemini sessions already show
  • Makes it easy to see at a glance which model was used for each turn, including when models change mid-session

How it works

Codex writes a turn_context entry at the start of each user turn containing the active model. The parser now reads this and stamps it on all messages in that turn.

Changes

  • Parse turn_context entries from Codex JSONL and extract the model field
  • Track current model in the session builder and apply it to all subsequent messages (both text and tool calls)
  • Add CodexTurnContextJSON test helper
  • Three test cases: model applied to messages, model changes across turns, no turn_context

Test plan

  • New unit tests pass (TestParseCodexSession_TurnContextModel)
  • All existing Codex parser tests pass (27 tests)
  • go vet and go fmt clean
  • Verify with real Codex session files containing turn_context entries

🤖 Generated with Claude Code

Codex JSONL files include turn_context entries with a model field
(e.g. "gpt-5-codex") written once per user turn. Extract this and
apply it to subsequent messages, matching how Gemini already parses
per-message model names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented Mar 19, 2026

roborev: Combined Review (a6b177d)

Verdict: The PR successfully propagates model metadata, but requires a
fix to prevent stale model state across turns.

Medium

  • Location: internal/parser/codex.go:69
    Problem: currentModel is only updated when turn_context.payload.model is non-empty. A later turn_context that omits or clears model will leave the previous turn's model in place, misattributing all subsequent messages and tool calls.
    Fix: Reset the state on every turn_context entry (e.g., b.currentModel = payload.Get("model").Str)
    and add a regression test for a turn with a missing/empty model following a modeled turn.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

A turn_context with an empty/missing model field must clear the
previous turn's model, otherwise messages get misattributed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented Mar 19, 2026

roborev: Combined Review (24dc878)

Summary Verdict: The code is clean; no issues of medium or higher severity were found.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@wesm wesm merged commit fc39dbd into wesm:main Mar 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants