Skip to content

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

Open

Description

@LAP87

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/user/.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

Activity

  1. added
    bug
    CLI
    custom-model
    config
    on May 26, 2026
  2. yui-stingray commented on May 27, 2026

    @yui-stingray

    I checked current origin/main, and the code path seems to match the report.

    OpenAiModelsManager::new() seeds remote_models from the bundled catalog, and get_model_info() reads the current in-memory remote_models directly before calling construct_model_info_from_candidates(...). I do not see a refresh/cache-load step on that lookup path. The models_cache.json path is currently reached through refresh_available_models(...) / try_load_cache(), for example via catalog/listing flows, rather than by get_model_info() itself.

    A focused regression test would be useful here: pre-populate a fresh models_cache.json with a custom model, construct OpenAiModelsManager, call get_model_info() for that custom model before any explicit catalog refresh, and assert that it uses the cached model metadata instead of fallback metadata. That should fail on the current path and would pin down whether the fix belongs in construction, get_model_info(), or turn setup before metadata lookup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugconfigcustom-model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions