Skip to content

fix(codex): stop the model-migration dialog blocking session start - #92

Merged
aixle-com[bot] merged 7 commits into
developfrom
feature/codex-model-migration-dialog
Aug 13, 2026
Merged

aixle-com[bot] merged 7 commits into
developfrom
feature/codex-model-migration-dialog

Conversation

@aixle-com

@aixle-com aixle-com Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What

Starting a session with the Codex agent no longer stops on the Codex CLI
"try the new model" dialog.

~/.codex/config.toml is generated by Agents::CodexAdapter#generate_config_toml.
The dialog is driven by the CLI's startup check
(codex-rs/tui/src/app/startup_prompts.rs → should_show_model_migration_prompt):
it fires when the model the CLI is about to run has an upgrade entry in the
model catalog and notice.model_migrations[<that model>] does not already point
at that exact upgrade target. Two things broke that:

  1. The acknowledgement was only written when the session pinned a model. Without
    one the CLI runs the catalog default (config.model.unwrap_or(bootstrap.default_model)),
    which was never acknowledged.
  2. The target was a hardcoded slug, LATEST_TARGET_MODEL = "gpt-5.4". The
    catalog has moved past it — gpt-5.4 is now itself migrated to
    gpt-5.6-terra (see codex-rs/models-manager/models.json) — so the written
    mapping never matched and the dialog came back.

How

  • [notice.model_migrations] is now built from the live model catalog (the
    same /backend-api/codex/models response the CLI reads): every model that
    advertises an upgrade is pre-acknowledged, so the suppression holds whether
    or not the session pinned a model, and it cannot go stale when OpenAI moves
    the target. Cached 6h per account; only non-empty results are cached, so a
    transient API failure can't pin an empty map.
  • FALLBACK_MODEL_MIGRATIONS replaces LATEST_TARGET_MODEL as the offline
    fallback (expired token / unreachable API). It mirrors the mappings the CLI
    ships in its bundled catalog.
  • [notice] also pre-acknowledges hide_gpt5_1_migration_prompt and
    hide_gpt-5.1-codex-max_migration_prompt — the two model prompts the CLI still
    gates on a dedicated flag rather than on the migration map.
  • Only slug-shaped entries (MODEL_SLUG_FORMAT) are emitted, so a hostile or
    malformed slug can't corrupt config.toml; the CLI compares the parsed TOML
    key, and the suppression shouldn't hinge on escape handling inside a quoted key.
  • CODEX_CLIENT_VERSION 0.116.0 → 0.147.0. The models endpoint gates the
    catalog on client_version (each model carries a minimal_client_version; the
    gpt-5.6 family needs ≥ 0.144.0), which is why the profile default-model picker
    showed no gpt-5.6 entries — the comment on task fix(admin): keep record header actions inside the page #534.

Existing suppression (trust dialog, full-access warning, rate-limit model nudge)
is unchanged.

Testing

docker compose -f docker-compose.ci.yml run --rm --no-deps web make check_all
(backend: rails test + rubocop + brakeman; frontend: eslint + tsc + vitest).

New cases in test/services/agents/codex_adapter_test.rb:

  • the catalog's target is acknowledged for the pinned model;
  • migrations are acknowledged for models the session did not pin (the
    catalog-default case);
  • a new catalog target is tracked instead of a hardcoded slug;
  • the shipped fallback map is used when the catalog is unreachable (401);
  • non-slug-shaped catalog entries are dropped;
  • the remaining startup notices (hide_full_access_warning,
    hide_rate_limit_model_nudge, both hide_*_migration_prompt keys, project
    trust) stay set;
  • auth_setup_files still writes a pre-auth config.toml without calling the
    models API;
  • the models request carries a client_version new enough for the current
    catalog, and list-visible gpt-5.6 models come back mapped.

Known limitation

config_files only receives the credential hash, not the AgentCredential
record, so a 401 here can't refresh the token the way
fetch_available_models(credential:) does — it falls back to the static map
instead. Plumbing the record through AgentCredentialsService#write_to_container
would touch every adapter and is out of scope for this fix.

Task: #534

🤖 Generated with Claude Code

Alex (Aixle agent) added 2 commits August 12, 2026 23:28
Codex CLI shows the "try the new model" dialog unless
notice.model_migrations[<model it is about to run>] already points at the
exact upgrade target the model catalog advertises
(codex-rs/tui/src/app/startup_prompts.rs). Two things broke that:

- the acknowledgement was written only when the session pinned a model,
  while the CLI runs the catalog default when it does not, and
- the target was a hardcoded slug (gpt-5.4) that the catalog has since
  moved past — gpt-5.4 is now itself migrated to gpt-5.6-terra, so the
  acknowledgement never matched.

Build the map from the live catalog instead (cached per account), keep the
mappings the CLI ships as an offline fallback, and pre-acknowledge the two
remaining flag-gated model prompts.

The catalog is also gated by the client_version we send: models carry a
minimal_client_version and the endpoint hides the ones an older client
cannot run, which is why the gpt-5.6 family never appeared in the default
model picker at 0.116.0.

Signed-off-by: Alex (Aixle agent) <[email protected]>
@aixle-com
aixle-com Bot force-pushed the feature/codex-model-migration-dialog branch from 96f1d59 to c2843c1 Compare August 12, 2026 23:28
Comment thread app/services/agents/codex_adapter.rb Resolved
Alex (Aixle agent) added 5 commits August 13, 2026 09:17
…alog

Addresses PR #92 review feedback.

The character class in toml_string held its range endpoints as raw NUL and
0x1f bytes, so git classified the whole file as binary and the review diff
was unreadable; they are now \u escapes. A .gitattributes rule marks Ruby
sources as text so a stray control byte cannot hide a diff again.

The catalog upgrade map is no longer cached: the migration target is exactly
the value that must not go stale, and config.toml is written once per
container start.

Signed-off-by: Alex (Aixle agent) <[email protected]>
Addresses PR #92 review feedback.

CodexAdapter spoke HTTP directly in two places: the model-catalog GET to
chatgpt.com and the OAuth token POST to auth.openai.com, together with the
endpoint/version/client-id constants, form encoding, status branching and
JSON parsing.

Codex::Api is now the transport layer for both, modelled on the existing
Coder::Api: class methods returning parsed Model/Tokens structs, and an
error hierarchy (HTTPError/UnauthorizedError/TransportError/TimeoutError/
ParseError) so callers rescue once. 401 gets its own class because it is
the one status with a domain meaning — the adapter holds a refresh token
and can retry.

The adapter keeps only the domain decisions: which models to list, when a
rejected token is worth refreshing, how the migration map becomes TOML, and
the token-rotation guard. Same endpoints, query param, headers, timeouts
and fallbacks — no behaviour change.

Signed-off-by: Alex (Aixle agent) <[email protected]>
…l-migration-dialog

Signed-off-by: Alex (Aixle agent) <[email protected]>
Minitest/RefutePredicate is enabled in .rubocop.yml (unlike the parked
AssertPredicate), so the two negative predicate assertions have to use it.

Signed-off-by: Alex (Aixle agent) <[email protected]>
@aixle-com
aixle-com Bot merged commit 55fea1c into develop Aug 13, 2026
7 checks passed
artempartos added a commit that referenced this pull request Dec 2, 2026
… re-resolve (#976)

* fix(deps): bump websocket-driver to 0.9.2 and websocket-extensions to 0.3.0

ActionCable's server-side WebSocket framing. Fixes GHSA-pf93-24xc-xgxc
(critical), GHSA-5qm2-87xf-x3ff and GHSA-7c6x-34q5-4g2j (Dependabot
alerts #89-#92). 0.9.2 (2026-12-01) also buffers data written before
`start`, which is the order ActionCable uses (hijack, then start).

Supersedes #965 and #966.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* fix(deps): re-resolve cross-spawn to 7.1.2 and tar to 7.5.24

cross-spawn 7.1.x fixes GHSA-ghv9-86vm-4v8m (alert #87, Windows-only;
we run eslint on Linux). tar 7.5.24 fixes GHSA-ph3c-p786-j4rp; the
alert #88 advisory itself is fixed only in tar 8, which pacote and
node-gyp do not accept yet. Lock-only, no manifest change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

---------

Signed-off-by: Artem Petrov <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant