codex - 💡(How to fix) Fix OSS mode: Custom models not loaded from models_cache.json at turn setup

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…

When running Codex in --oss mode with custom models (e.g. via Ollama), get_model_info() fails to find the model and displays: "Model metadata for X not found. Defaulting to fallback metadata; this can degrade performance and cause issues."

Root Cause

OpenAiModelsManager initializes remote_models from the bundled models.json (6 OpenAI models only). The user's models_cache.json (populated by a script that syncs Ollama models into Codex's model cache) is never read automatically — get_model_info() reads remote_models directly without triggering a cache load.

The cache is only consulted when list_models() is called via refresh_available_models(), which happens asynchronously in the TUI model picker, not at turn setup.

Fix Action

Fix / Workaround

Workaround guide: https://gist.github.com/LAP87/045cde0227512408d268c67cb49123be

Workaround (user-side)

Even with model_catalog_json, the JSON must use protocol-compliant values:

  • visibility: list / hide / none (not custom)
  • apply_patch_tool_type: freeform (not unified)
  • shell_type: default / local / unified_exec / disabled / shell_command
  • web_search_tool_type: text / text_and_image

Code Example

model_catalog_json = "/home/lenny/.codex/model_catalog.json"
RAW_BUFFERClick to expand / collapse

OSS mode: Custom models not loaded from models_cache.json at turn setup

Workaround guide: https://gist.github.com/LAP87/045cde0227512408d268c67cb49123be

Summary

When running Codex in --oss mode with custom models (e.g. via Ollama), get_model_info() fails to find the model and displays: "Model metadata for X not found. Defaulting to fallback metadata; this can degrade performance and cause issues."

Root cause

OpenAiModelsManager initializes remote_models from the bundled models.json (6 OpenAI models only). The user's models_cache.json (populated by a script that syncs Ollama models into Codex's model cache) is never read automatically — get_model_info() reads remote_models directly without triggering a cache load.

The cache is only consulted when list_models() is called via refresh_available_models(), which happens asynchronously in the TUI model picker, not at turn setup.

Workaround (user-side)

The only way to make custom models immediately available is setting model_catalog_json in ~/.codex/config.toml:

model_catalog_json = "/home/lenny/.codex/model_catalog.json"

This forces StaticModelsManager, which loads all models at startup. The catalog file should contain a {"models": [...]} array with model entries matching the protocol schema.

Request

It would be better if --oss mode automatically loaded models_cache.json into the model catalog at startup, so users don't need model_catalog_json + a separate file + enum-value massaging just to use their Ollama models without warnings.

Metadata enum gotcha (bonus)

Even with model_catalog_json, the JSON must use protocol-compliant values:

  • visibility: list / hide / none (not custom)
  • apply_patch_tool_type: freeform (not unified)
  • shell_type: default / local / unified_exec / disabled / shell_command
  • web_search_tool_type: text / text_and_image

Otherwise Codex rejects the catalog at parse time with "unknown variant" errors.

Environment

  • Codex v0.134.0
  • Ollama as local provider

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