`/clear` should preserve the active model in each CLI terminal session

Open 💬 1 comment Opened Aug 1, 2026 by carter003
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

codex-cli 0.146.0

What subscription do you have?

ChatGPT subscription

Which model were you using?

This affects any model selection. For example, one terminal may use gpt-5.6-terra while another uses a different model.

What platform and terminal are you using?

Linux x86_64; multiple Codex CLI terminals running concurrently.

What issue are you seeing?

When several Codex CLI terminals are open, each terminal often has a distinct purpose and therefore needs a different model. However, /model persists the selected model to the shared ~/.codex/config.toml.

When /clear creates a new session, Codex reloads configuration from disk. As a result, the terminal can switch to whichever model was most recently selected in another terminal, rather than retaining the model that was active immediately before /clear.

Example:

  1. Terminal A is using gpt-5.6-terra for one type of task.
  2. Terminal B is used for another purpose and selects a different model.
  3. Terminal A runs /clear.
  4. Terminal A starts the new session with Terminal B's most recently persisted model.

This makes concurrent CLI workflows unreliable: clearing a conversation unexpectedly changes the model for that terminal.

What steps can reproduce the bug?

  1. Start Codex in terminal A and select model A with /model.
  2. Start Codex in terminal B and select model B with /model.
  3. Return to terminal A and run /clear.
  4. Observe that the new session in terminal A uses model B instead of model A.

What is the expected behavior?

/clear should preserve the active session-local model when it creates a new session.

The intended precedence should be:

current terminal's active model
  > terminal-specific CLI/profile/config overrides
  > shared global config.toml default

Each terminal should retain its own selected model across /clear; one terminal's /model choice should not change another terminal's new session.

Additional information

The problem appears to be in the new-thread lifecycle:

  • /model writes the selection to the shared configuration.
  • /clear refreshes in-memory configuration from disk before creating its new session.
  • The current model is read for failure recovery but is not reapplied on the normal new-session path.

A narrow fix would be to capture the active model before refreshing configuration, then reapply it after creating the fresh session config and applying managed new-thread defaults. The same session-local preservation should be considered for model_reasoning_effort and model_provider.

Conceptually:

let current_model = self.chat_widget.current_model().to_string();

self.refresh_in_memory_config_from_disk_best_effort("starting a new thread")
    .await;

let mut config = self.fresh_session_config();
apply_managed_new_thread_defaults(...);

config.model = Some(current_model);

The configuration refresh and managed defaults should remain intact; only the current terminal's model selection should be restored afterward. A regression test should run two independent TUI sessions with different models, clear one of them, and assert that it retains its own model.

View original on GitHub ↗

1 Comment

github-actions[bot] contributor · 27 days ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #35509

Powered by Codex Action