Skip to content

Native subagent ignores explicit model_provider override while model override works #40858

Open

Description

@JiuGHim

What version of Codex CLI is running?

codex-cli 0.149.1

What subscription do you have?

plus

Which model were you using?

Parent: gpt-5.6-luna (xhigh) Subagent: MiniMax-M3

What platform is your computer?

Linux 6.17.0-29-generic x86_64 x86_64

What terminal emulator and version are you using (if applicable)?

GNOME Terminal 3.52.0 using VTE 0.76.0 +BIDI +GNUTLS +ICU +SYSTEMD

Codex doctor report

What issue are you seeing?

Native subagent roles appear to ignore an explicit model_provider override while correctly applying the model and model_reasoning_effort overrides.

My parent session uses ChatGPT/OpenAI:

  • Parent model: gpt-5.6-luna
  • Parent provider: OpenAI / ChatGPT account

The subagent role explicitly specifies:

model = "MiniMax-M3"
model_provider = "minimax"
model_reasoning_effort = "high"

### What steps can reproduce the bug?

1. Register a custom Responses API provider in ~/.codex/config.toml:

[features]
multi_agent = true

[agents]
enabled = true
default_subagent_model = "gpt-5.6-luna"
default_subagent_reasoning_effort = "xhigh"

[model_providers.minimax]
name = "MiniMax"
base_url = "https://api.minimaxi.com/v1"
experimental_bearer_token = "<redacted>"
wire_api = "responses"

Do NOT globally set:

model_provider = "minimax"

The parent session should remain authenticated through ChatGPT/OpenAI.

2. Create a native subagent role at:

~/.codex/agents/chain-test.toml

with the following configuration:

name = "chain_test"

description = """
Diagnostic subagent for testing cross-provider delegation.
"""

model = "MiniMax-M3"
model_provider = "minimax"
model_reasoning_effort = "high"

sandbox_mode = "read-only"

developer_instructions = """
Inspect the current repository.
Actually execute:
- pwd
- git status
- ls

Do not modify any files.
"""

3. Start the normal ChatGPT-authenticated Codex CLI:

codex

4. Ask the parent agent:

You must use the chain_test subagent for this task.
Do not perform the task yourself.

Inspect the current repository and actually run:
- pwd
- git status
- ls

Wait for chain_test to finish and return its result.

5. Codex successfully resolves the role and spawns the child:

Spawned <thread-id> (MiniMax-M3 high)

However, the child fails before running the requested commands with:

The 'MiniMax-M3' model is not supported when using Codex with a ChatGPT account.

6. As a control test, use the SAME ~/.codex configuration and SAME ChatGPT-authenticated environment, but override the provider at the session level:

codex exec \
  -C "$PWD" \
  --sandbox danger-full-access \
  -c 'model_provider="minimax"' \
  -c 'model="MiniMax-M3"' \
  -c 'model_reasoning_effort="high"' \
  "Actually execute pwd and return the result."

This works correctly.

Codex reports:

model: MiniMax-M3
provider: minimax

The MiniMax model then successfully performs the shell tool call.

Therefore, the custom provider itself works correctly from the same ChatGPT-authenticated CODEX_HOME.

The failure appears specific to applying the explicit model_provider override from a native subagent role: the model override is applied, but the provider appears to remain inherited from the OpenAI/ChatGPT parent.

### What is the expected behavior?

When a native subagent role explicitly specifies both:

model = "MiniMax-M3"
model_provider = "minimax"

the spawned child should use both overrides.

Expected configuration:

Parent:
  model: gpt-5.6-luna
  provider: openai / ChatGPT

Child:
  model: MiniMax-M3
  provider: minimax

The parent provider should only be inherited when the subagent role does not explicitly specify its own model_provider.

This should allow native subagents to use a different custom provider from the parent session.

### Additional information

I can also reproduce the same behavior in the ChatGPT/Codex desktop app.

The desktop app is using its bundled Codex runtime:

/usr/lib/chatgpt/resources/codex --version
codex-cli 0.150.0-alpha.8

The desktop native subagent also applies the MiniMax-M3 model override, but then fails with the same ChatGPT-account error instead of using the explicitly configured minimax provider.

The custom provider itself is confirmed to work.

Using the same normal ChatGPT-authenticated ~/.codex environment, a session-level override works successfully:

codex exec \
  -C "$PWD" \
  --sandbox danger-full-access \
  -c 'model_provider="minimax"' \
  -c 'model="MiniMax-M3"' \
  -c 'model_reasoning_effort="high"' \
  "Actually execute pwd and return the result."

Codex reports:

model: MiniMax-M3
provider: minimax

and MiniMax-M3 successfully performs the shell tool call.

So this does not appear to be a general custom-provider, authentication, or MiniMax compatibility issue.

The behavior appears specific to native subagent configuration:

- Subagent model override works.
- Subagent reasoning-effort override works.
- Explicit subagent model_provider override does not appear to take effect.

A practical use case is keeping an OpenAI/ChatGPT model as the parent/orchestrator while delegating implementation, testing, review, or exploration to specialized or lower-cost models on other providers.

For example:

OpenAI / ChatGPT parent
        |
        +-- MiniMax backend subagent
        +-- MiniMax frontend subagent
        +-- MiniMax QA subagent
        +-- MiniMax reviewer subagent

Activity

  1. added
    bug
    on Aug 26, 2026
  2. added
    CLI
    subagent
    custom-model
    config
    on Aug 26, 2026
  3. github-actions commented on Aug 26, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. Razyrickk commented on Aug 27, 2026

    @Razyrickk

    My issue too. I need to use custom provider for subagents while GPT is the controller.

  5. JiuGHim commented on Aug 27, 2026

    @JiuGHim
    Author

    My issue too. I need to use custom provider for subagents while GPT is the controller.

    Exactly. My goal is also to keep gpt5.6 sol as the controller while using a custom provider such as MiniMax for native subagents.
    I also confirmed that the custom provider works correctly in the same ChatGPT-authenticated CODEX_HOME when overridden at the session level. The failure only happens when model_provider is specified in the native subagent role: model is applied, but the provider still appears to be inherited from the parent.

  6. Tian99Yu commented on Aug 29, 2026

    @Tian99Yu

    exactly the same issue for me !!
    sol as the coordinator, but third party agent as the worker. It used to work 2 months ago!! This is a regression

    #39299 because of this PR

  7. yiaany commented on Aug 29, 2026

    @yiaany

    I'd like to work on this. I can reproduce the regression and will start by adding a failing test for the explicit model_provider override in native subagent roles, then trace the config inheritance introduced around #39299 and implement a focused fix.

    Is this approach aligned with the maintainers' expectations?

  8. jfedor commented on Aug 31, 2026

    @jfedor

    I can reproduce this on newer versions with Z.ai:

    • macOS 26.6.2
    • Codex CLI 0.151.0
    • Codex desktop app 26.825.51511
    • Desktop embedded CLI 0.151.0-alpha.7.2
    • Parent authenticated with ChatGPT/OpenAI
    • Child model: glm-5.3-flash
    • Child provider: custom ZAI Responses provider

    Direct control test succeeds:

    codex exec --profile zai ...
    => ZAI_DIRECT_OK
    

    Native subagent test fails:

    The 'glm-5.3-flash' model is not supported when using Codex with a ChatGPT account.
    

    The child session metadata shows:

    {
      "agent_role": "zai_worker",
      "model_provider": "openai",
      "model": "glm-5.3-flash"
    }

    So the model override is applied, but model_provider = "ZAI" is discarded.

    This appears consistent with PR #39299 preserving parent-owned providers. If that restriction is intentional, the custom-agent documentation should state that model_provider cannot be overridden and Codex should reject or warn about the ineffective field. If cross-provider native delegation is intended, the child needs to carry the resolved provider and trusted user-level provider configuration.

  9. Bozentan commented on Aug 31, 2026

    @Bozentan

    Update: I can also reproduce the same provider-inheritance behavior on Codex CLI 0.152.0-alpha.7, the current published alpha as of September 1, 2026.

    Tested with:

    • Parent authenticated with ChatGPT/OpenAI
    • Child model: z-ai/glm-5.3-flash
    • Child provider configured as OpenRouter

    The native subagent is created, but fails during session_startup_prewarm with:

    The 'z-ai/glm-5.3-flash' model is not supported when using Codex with a ChatGPT account.
    

    This is the same failure pattern: the role's model override is applied while the child still uses the parent's OpenAI/ChatGPT provider. Cross-provider native delegation therefore does not appear to be fixed in 0.152.0-alpha.7.

  10. jfedor commented on Aug 31, 2026

    @jfedor

    @Bozentan interesting. On Codex CLI 0.151.0 it works fine

  11. Bozentan commented on Sep 1, 2026

    @Bozentan

    Update: the candidate has now been rebased onto
    openai/codex:latest-alpha-cli at 0.154.0-alpha.1 and finalized as
    af3072ebbc.
    The review mirror is Bozentan/codex#2.

    The final implementation fixes both halves of the problem:

    • a trusted user-defined role can select an already configured provider through
      a user-owned subagent_model_provider_allowlist;
    • MultiAgent V2 keeps native OpenAI-to-OpenAI agent_message transport intact,
      but lowers a plaintext task to one ordinary user message when the
      destination provider is non-OpenAI.

    The provider boundary is intentionally narrow:

    • project/session/role layers cannot grant provider access;
    • the role cannot define or replace provider credentials;
    • each child receives an isolated provider, auth state, model manager, and
      catalog;
    • cross-provider history forks are rejected, while an implicit provider switch
      starts a fresh child;
    • cold resume revalidates the exact provider configuration and authorization;
    • encrypted external task content fails closed instead of being forwarded or
      silently discarded.

    Nested delegation is covered in both directions, including a non-OpenAI V2
    agent selecting a second authorized provider role. There is no intermediate
    OpenAI child and no duplicated parent context.

    Verification on Windows includes 6/6 cross-provider V1/V2 E2E tests, 17/17
    app-server V2 tests (including real remote-compaction output), 417/417 affected
    package tests, focused routing/resume/config/CLI suites, Rust formatting and
    targeted fix checks, plus a successful optimized release build of
    codex-cli 0.154.0-alpha.1.

    The 6/6 cross-provider/nested suite and 17/17 app-server V2 suite were rerun
    against final head af3072e after the last architecture-audit and formatting
    pass.

    This candidate also addresses #34833, #38656, #17598, and #27712. It does not
    add generic provider-routing fields or embed any provider endpoint, credential,
    or private role definition.

  12. magic3007 commented on Sep 2, 2026

    @magic3007

    I implemented and locally validated a candidate fix for this issue in the fork commit below:

    magic3007@30e9f16e2c

    The implementation:

    • resolves a role's model_provider from the parent-owned provider registry, preserving the parent's provider for unknown or role-local provider IDs;
    • routes a cross-provider child to its configured Responses API endpoint;
    • starts cross-provider children with fresh history by default, and rejects explicit cross-provider history inheritance to avoid forwarding provider-bound encrypted items;
    • supports plaintext spawn_agent, send_message, and followup_task payloads with a hard 10 KB bound;
    • updates the config schema and adds integration coverage using distinct root and child mock endpoints.

    Targeted codex-core tests and scoped Clippy checks pass. The complete fork branch (including a separate third-party Responses stream compatibility fix) is:

    https://github.com/magic3007/codex/tree/fix/subagent-model-provider

  13. f1vestars commented on Sep 3, 2026

    @f1vestars

    I can confirm this issue with OpenRouter-backed native subagents in Codex Desktop on macOS.

    My parent thread uses ChatGPT/OpenAI authentication. I configured custom native subagent roles with explicit OpenRouter models, for example:

    name = "partisan_docs_researcher"
    description = "Read-only researcher for official documentation."
    model = "deepseek/deepseek-v4-flash-0731"
    model_provider = "openrouter"
    model_reasoning_effort = "high"
    sandbox_mode = "read-only"
    
    My OpenRouter provider configuration is Responses-compatible:
    [model_providers.openrouter]
    name = "OpenRouter"
    base_url = "https://openrouter.ai/api/v1"
    wire_api = "responses"
    
    400 invalid_request_error:
    The 'deepseek/deepseek-v4-flash-0731' model is not supported when using Codex with a ChatGPT account.
  14. AeonPrime commented on Sep 4, 2026

    @AeonPrime

    I can confirm this issue persists with opencode go models that follow the /v1/responses endpoint schema.
    I've gotten around it with a script that starts workers, but that feels very unelegant.

    VS Code Codex extension 26.901.22334 and the linux CLI client affected the same way.

  15. Tian99Yu commented on Sep 4, 2026

    @Tian99Yu

    I can confirm this issue persists with opencode go models that follow the /v1/responses endpoint schema. I've gotten around it with a script that starts workers, but that feels very unelegant.

    VS Code Codex extension 26.901.22334 and the linux CLI client affected the same way.

    As another unelegant approach, I wrote a plugin with part of the functionality to start an opencode agent via the opencode CLI, as an approximation of a native subagent

    And yes, this is not the way I want to use it :(

  16. grc-jatin-garg commented on Sep 8, 2026

    @grc-jatin-garg

    Hi is there some fix being implemented for this? Wanted to use external provider subagents natively inside codex with existing openAI models.

  17. Razyrickk commented on Sep 8, 2026

    @Razyrickk

    Hi is there some fix being implemented for this? Wanted to use external provider subagents natively inside codex with existing openAI models.

    not yet as per latest stable release. For mine, i created a script that runs parent level codex worker that uses external provider, since parent level supports it (while subagents doesn't, which is weird). But it's inefficient way to do it since controller has to poll-like monitor it, instead of notifying the controller once finished.

  18. grc-jatin-garg commented on Sep 8, 2026

    @grc-jatin-garg

    Hi is there some fix being implemented for this? Wanted to use external provider subagents natively inside codex with existing openAI models.

    not yet as per latest stable release. For mine, i created a script that runs parent level codex worker that uses external provider, since parent level supports it (while subagents doesn't, which is weird). But it's inefficient way to do it since controller has to poll-like monitor it, instead of notifying the controller once finished.

    Yup I did the same thing, wrote a minimal script, but a "native" subagent support works much better, claude_code has this support,

  19. grc-jatin-garg commented on Sep 9, 2026

    @grc-jatin-garg

    Hi @Razyrickk I think there is one easy way-around, have a local proxy of sort, all of the codex traffic goes via that proxy, for OpenAI models, proxy routes traffic as it is to OpenAI endpoints, for other model providers, proxy routes traffic accordingly with relevant headers.

  20. NathanNT commented on Sep 15, 2026

    @NathanNT

    I ran into the same issue and put together a small compatibility kit that preserves the subagent role's custom model_provider while keeping the parent on GPT. Sharing it in case it's useful as a temporary workaround : https://github.com/NathanNT/codex-mux

  21. Mazyod commented on Sep 15, 2026

    @Mazyod

    I ran into the same issue and put together a small compatibility kit that preserves the subagent role's custom model_provider while keeping the parent on GPT. Sharing it in case it's useful as a temporary workaround : https://github.com/NathanNT/codex-mux

    Why would you upload opaque executables and ask people to run them...

  22. NathanNT commented on Oct 2, 2026

    @NathanNT

    I ran into the same issue and put together a small compatibility kit that preserves the subagent role's custom model_provider while keeping the parent on GPT. Sharing it in case it's useful as a temporary workaround : https://github.com/NathanNT/codex-mux

    Why would you upload opaque executables and ask people to run them...

    The executable was just Codex built from OpenAI pinned upstream source with the patch from this repo applied. build.ps1 clones the pinned Codex version, applies the patch and builds codex with Cargo.
    The release was only there as a convenience for people who didn't want to compile Codex. I've removed it if you prefer that way, but anyone can still review the patch and run build.ps1 to build the patched binary from source.

  23. added a commit that references this issue on Oct 26, 2026
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-modelsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions