openai / openai/codex

CLI TUI: /provider slash command to switch model_provider mid-session

Open
#41,342 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

app-server CLI config custom-model enhancement TUI
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What variant of Codex are you using?

CLI (TUI)

What feature would you like to see?

A /provider slash command in the CLI TUI that switches model_provider mid-session, with these properties:

  • Lists all providers registered in the active config (whatever [model_providers.*] tables exist) plus the implicit OpenAI subscription backend
  • Switching rebinds the next turn's model_provider, model, and env_key to the chosen profile's settings, without losing the existing conversation history
  • Optionally accepts a profile name as argument (/provider minimax jumps directly; bare /provider opens a picker)
  • The TUI's /model selector should also surface the new provider's models when invoked after a switch

Today the only way to switch provider is to exit the TUI and rerun codex --profile <name>, which loses the entire conversation history. cx fork --last -p <new> (mentioned in community docs) preserves history but still forces a new TUI session. The Codex Desktop UI gets a sidebar profile picker (recently requested in #39527) — the CLI TUI should have parity.

Additional information

Use case: I maintain a single-machine registry of ~17 named provider profiles (minimax, ZAI glm-5.3, xiaomi mimo-v2.5-pro, qwen-3.7-plus, volc ark-code-latest, 10-0..3 direct sglang, etc.). Mid-task I regularly want to ask a second model for a sanity check on a refactor — without losing the refactor's conversation history, and without opening a new terminal.

Today's workaround: I wrote a wrapper bin/cx-switch that runs codex fork --last -p <new> to fork the current session with a new provider. This preserves history but is a fork (new conversation ID, the original session stays paused in codex resume history). It works, but it's not in-TUI and breaks the "single running session" mental model.

What the schema already supports: The v2 app-server protocol (ThreadStartParams, ThreadForkParams, ThreadResumeParams) accepts modelProvider overrides when starting a new thread. The TurnStartParams schema accepts model, cwd, effort, etc. as per-turn overrides, but NOT modelProvider. Implementing /provider would require either:

  1. A new setSessionProvider RPC (or extending TurnStartParams with modelProvider) on the app-server protocol, then binding it to a /provider slash command in the TUI frontend, or
  2. A pure-TUI-side client that forks the current thread internally on /provider <name> and discards the old session pointer. This is the cheaper ship path.

Related issues:

  • #4849 — "Make config.toml profiles selectable via CLI" (closed 2026-08-05 by maintainer with one-liner "Named configurations are selectable with --profile." — that's the wrapper workaround we already use; not in-TUI). The same issue proposed /provider as one of the UX options.
  • #35728 — "show sessions from all providers in the sidebar and make model switching provider-aware" (open, Desktop-focused)
  • #39527 — "Add a config profile selector to Codex Desktop" (open, Desktop-only)
  • #38104 — "Support selecting a config profile for app-server and Desktop via environment variable" (open, CODEX_CONFIG_PROFILE env var; would help non-TUI launchers but not in-TUI)
  • #22483 — "Disconnected when using custom provider and no ability to switch providers or profiles" (open, related but bug-shaped)

Why I'm filing this even though #4849 was closed: the maintainer's "use --profile" answer sidesteps the actual UX problem (history loss + new terminal) and the OP specifically called out "/provider" as the natural UX. The Discord/community thread linked from #4849 has multiple users (e.g. @tom-nash, 13 thumbs up on comment dated 2026-02-02) describing the same problem. The cluster of related open issues (#35728, #39527, #38104) shows this is a recurring ask across CLI / Desktop / app-server surfaces.

If a quick win is possible via a /provider slash command bound to a ThreadForkParams + modelProvider override call, that would close the most painful part of the gap without waiting for broader provider-aware session work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the CLI TUI slash-command handling and the app-server ThreadForkParams and TurnStartParams paths mentioned in the issue. Compare the setSessionProvider and per-turn override options, then determine how /model should read the selected provider's models. Done means switching provider in one running TUI preserves conversation history and updates the next turn's provider, model, and env_key.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.