Skip to content

Rust: ~/.codex/config.toml model_providers overrides ignored (regression between rust-v0.23.0-alpha and -alpha.5) #2482

@ishibashi-futos

Description

@ishibashi-futos

Thank you for your work on Codex! This is a regression in the Rust CLI configuration handling.

What version of Codex is running?

  • codex --version: rust-v0.23.0-alpha.5 (regression appears between rust-v0.23.0-alpha and rust-v0.23.0-alpha.5)

Which model were you using?

  • Any; reproduces with built-in provider ids such as openai and oss.

What platform is your computer?

  • e.g., macOS (uname -mprs), Linux, or Windows. Please fill in.

What steps can reproduce the bug?

  1. Create/update ~/.codex/config.toml with a user override for a built-in model provider key:
   model_provider = "oss"

   [model_providers.oss]
   name = "Open Source"
   base_url = "http://my-ollama.example.com:11434/v1"
  1. Run Codex (Rust CLI), e.g.:
    • codex -m gpt-oss:20b --oss or codex with defaults
  2. Observe that requests still use the built-in provider configuration instead of the user override (e.g., base_url is not changed).

What is the expected behavior?

  • User-defined entries under [model_providers.<id>] in ~/.codex/config.toml should override the built-in provider with the same , as documented (“override
    and amend the default set of model providers”).

What do you see instead?

  • The built-in provider entry wins; the user override is ignored when collides with a built-in key.

Additional information

  • Root cause:
    • codex-rs/core/src/config.rs merges built-ins with user-defined providers using:
      for (key, provider) in cfg.model_providers.into_iter() {
      model_providers.entry(key).or_insert(provider);
      }
  • or_insert prevents overriding an existing (built-in) entry with the same key, so user overrides for keys like openai, azure, ollama, or oss are ignored.
  • Background and related changes:
    • Introduced in the work to read model_provider/model_providers from config.toml and later work adding chat completions support and profiles; docs were
      updated to encourage overriding providers.
    • This behavior diverges from docs and breaks common use cases (e.g., overriding [model_providers.oss] base_url).
  • Proposed fix:
    • Replace or_insert with insert so user-defined providers replace built-ins on the same key:
      for (key, provider) in cfg.model_providers.into_iter() {
      model_providers.insert(key, provider);
      }
  • This aligns with the documentation (“override and amend”).
  • Suggested regression test:
    • Given model_provider = "oss" and a custom [model_providers.oss].base_url, assert that Config.model_provider.base_url equals the custom value.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions