Skip to content

fix: re-assert the configured model when resuming a Codex session - #168

Merged
PleasePrompto merged 1 commit into
PleasePrompto:mainfrom
ryuhaneul:fix/codex-resume-model
Jul 12, 2026
Merged

fix: re-assert the configured model when resuming a Codex session#168
PleasePrompto merged 1 commit into
PleasePrompto:mainfrom
ryuhaneul:fix/codex-resume-model

Conversation

@ryuhaneul

Copy link
Copy Markdown
Contributor

Problem

Switching /model to a different Codex model has no effect on chats that
already have a Codex session: codex exec resume runs the model stored in
the session at creation time, and the resume command builder passes no
model flag. Unlike Claude — which re-sends --model on every turn — the
new selection is silently ignored on resumed turns.

It can also hard-fail: if the new selection sets a reasoning effort the
stored model doesn't support (e.g. an effort level introduced with a newer
model generation), the resumed turn dies with
400 invalid_request_error: Invalid value ... reasoning.effort and the
turn is lost.

Reproduce: create a Codex session on an older model, /model to a newer
model plus a newer-only effort level, then send a message in the same chat
→ the CLI exits 1.

Fix

Mirror the fresh-session --model flag in _build_resume_command,
emitted under the same condition (only when a model is configured).
Verified against the Codex CLI: codex exec resume --model <new>
overrides the stored session model, and subsequent turn contexts record
the new model.

Tests

  • resume command asserts --model <value> placed before the --
    separator (the structure test previously asserted the flag's absence)
  • None/empty configured model omits the flag
  • existing resume ordering/structure assertions unchanged

2 files changed, +20/−3. Rollback = revert (no config/schema impact).

Note for merging alongside #164 (per-session reasoning effort):
#164 adds an effort re-assert in the same pre--- region of
_build_resume_command. The blocks compose in either merge order:
sandbox flags → --model → effort -c-- <session-id>.

Codex stores the model a session was created with. Without re-asserting the configured model, a later /model change is ignored on resumed turns, unlike Claude which re-sends --model every turn.

Mirror the fresh-session model flag in the resume command so the selected model and its reasoning effort stay consistent.
@PleasePrompto
PleasePrompto marked this pull request as ready for review July 12, 2026 06:04
@PleasePrompto
PleasePrompto merged commit baab0fc into PleasePrompto:main Jul 12, 2026
PleasePrompto added a commit that referenced this pull request Jul 12, 2026
- drop the now-unused windows_only parameter from _feed_stdin_and_close
- feed streaming stdin concurrently with the stdout read loop: a prompt
  larger than the OS pipe buffer could deadlock against a child that
  emits stdout before draining stdin (oneshot path already used
  communicate() and was safe)
- update #168-era resume-command tests to the stdin prompt marker

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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