codex - 💡(How to fix) Fix feat: /model support for LM Studio and Ollama local model switching [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17261Fetched 2026-04-10 03:43:14
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×5unlabeled ×3commented ×1

Error Message

error

Code Example

[model_context_windows]
  "qwen3.5-122b-a10b" = 32768
  "llama-3.2-3b" = 8192
RAW_BUFFERClick to expand / collapse

Problem

When running Codex with --oss (LM Studio or Ollama provider), the /model command only shows the static cloud model catalog from models.json, which contains no local models. This makes /model useless for OSS users who need to switch between locally loaded models.

Additional pain points with the current --oss experience:

  1. Auto-download on startup: ensure_oss_ready downloads the default openai/gpt-oss-20b model even when the user already has models loaded, forcing a 12GB download they didn't ask for
  2. No model persistence: Launching with --oss always defaults to openai/gpt-oss-20b regardless of what the user previously selected -- if that model doesn't exist on the server, the first prompt fails with a stream disconnect error
  3. No context window management: Local models don't report context window size via API, and Codex defaults unknown models to 272K tokens, which causes compaction to never trigger and eventually hits context overflow errors from the local server

Proposed Solution

Dynamic model listing in /model

When the active provider is lmstudio or ollama, /model fetches available models from the running local server (LM Studio's /models endpoint or Ollama's /api/tags) and presents them in a searchable picker.

Per-model context window configuration

On first selection of a local model, a context window picker appears (4K, 8K, 16K, 32K, 64K, 128K, 256K). The selection is persisted per-model in config.toml:

[model_context_windows]
"qwen3.5-122b-a10b" = 32768
"llama-3.2-3b" = 8192

Subsequent selections of the same model switch directly without re-prompting. Tab reopens the picker to change a saved value.

Startup improvements

  • Remove auto-download/pull from ensure_oss_ready -- require models to be pre-installed
  • Auto-select the first available model when the default isn't found on the server
  • Persist and restore the last selected model across sessions via config.toml

Reference Implementation

A working implementation is available here. Changes:

  • tui/src/oss_model_fetch.rs -- thin async HTTP helpers for model listing
  • config_toml.rs, config/edit.rs -- model_context_windows HashMap with ConfigEditsBuilder persistence
  • models-manager/model_info.rs -- per-model context window resolution (per-model > global > catalog default)
  • chatwidget.rs -- OSS model picker, context window picker, chained popup flow
  • list_selection_view.rs -- secondary_action field on SelectionItem (Tab key)
  • lmstudio/lib.rs, ollama/lib.rs -- return resolved model from ensure_oss_ready, no auto-download
  • All 1503 codex-tui tests pass, clippy clean

extent analysis

TL;DR

To fix the issues with Codex's --oss mode, update the model listing and selection logic to dynamically fetch available models from the local server and persist model context windows and selections.

Guidance

  • Update the /model command to fetch models from the local server's API (e.g., LM Studio's /models endpoint or Ollama's /api/tags) when the active provider is lmstudio or ollama.
  • Implement per-model context window configuration, allowing users to select a context window size (e.g., 4K, 8K, 16K) when selecting a local model, and persist this selection in config.toml.
  • Remove auto-download from ensure_oss_ready and instead require models to be pre-installed, auto-selecting the first available model when the default isn't found on the server.
  • Persist and restore the last selected model across sessions via config.toml.

Example

[model_context_windows]
"qwen3.5-122b-a10b" = 32768
"llama-3.2-3b" = 8192

This example shows how model context windows can be persisted in config.toml.

Notes

The proposed solution requires updates to multiple components, including tui/src/oss_model_fetch.rs, config_toml.rs, models-manager/model_info.rs, and others. A working implementation is available in the referenced GitHub commit.

Recommendation

Apply the proposed workaround by updating the model listing and selection logic, as well as implementing per-model context window configuration and persistence. This will improve the overall user experience for OSS users and address the current pain points.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING