Skip to content

Allow subagent roles to use custom model providers when parent agent is authenticated via ChatGPT #47752

Open

Description

@ArchdukeViel

What variant of Codex are you using?

CLI, IDE Extension (VS Code), Desktop App

Environment Details

  • Platform: Microsoft Windows NT 10.0.26200.0 x64 (Windows 11 Professional)
  • Codex CLI: 0.155.0 / 0.156.1
  • VS Code Extension: openai.chatgpt 26.917.62051
  • Desktop App: 26.917.8451.0
  • Terminal: PowerShell 7.6 / Windows Terminal / VS Code Integrated Terminal
  • Subscription / Auth: ChatGPT (Plus / Pro)
  • Parent Model: gpt-5.5 / gpt-6-luna (provider: openai)

What feature would you like to see?

We would like Codex to permit subagent roles (configured in .codex/agents/<role>.toml, e.g., worker.toml, explorer.toml, or custom roles) to specify and use alternative or local OpenAI-compatible model providers (such as local proxies/routers, Ollama, LM Studio, vLLM), even when the main coordinator/parent thread is authenticated via a ChatGPT subscription account (auth_provider = "chatgpt").

Currently, when the ChatGPT parent agent attempts to delegate tasks to a subagent role that declares a custom provider/model, the tool dispatcher blocks the spawn:

ERROR codex_core::tools::router: error=The selected agent uses a non-OpenAI model provider; retry with the corresponding `external_agents` collaboration tool.

Steps to Reproduce

  1. Configure a subagent role in ~/.codex/agents/worker.toml:
    model = "custom-subagent-model"
    provider = "my-local-gateway"
  2. In Codex (CLI, VS Code, or Desktop), start a session authenticated with ChatGPT (chatgpt.com auth mode, model gpt-5.5 or gpt-6-luna).
  3. Issue a prompt requiring parallel subagent delegation:
    "Please delegate to a worker subagent to inspect package.json and summarize dependencies."
  4. The parent model attempts to invoke the delegation tool, but codex_core::tools::router intercepts the call and fails with:
    error=The selected agent uses a non-OpenAI model provider; retry with the corresponding 'external_agents' collaboration tool.

Expected Behavior

Codex should permit the spawned subagent thread to initialize with the provider and endpoint configured in its role definition file (.codex/agents/<role>.toml), allowing hybrid multi-agent delegation without requiring the parent coordinator to switch away from its primary ChatGPT subscription session.

Value & Use Case

  1. Quota & Efficiency Optimization: Multi-agent delegation often handles repetitive, read-heavy, or exploratory subtasks (e.g. searching large file trees, summarizing lockfiles, running localized linters). Allowing subagents to use local or developer-routed models preserves primary ChatGPT reasoning quota for the coordinator.
  2. Hybrid Multi-Agent Architectures: Developers can leverage state-of-the-art OpenAI models for high-level reasoning and planning, while delegating high-volume bounded subtasks to self-hosted or domain-specialized models.

Proposed Solutions

  • Allow codex-rs/core/src/tools/router.rs to route subagent creation requests to the client instance associated with the role's declared provider.
  • Alternatively, provide an explicit configuration opt-in in config.toml:
    [multi_agent]
    allow_cross_provider_subagents = true

Activity

  1. added
    enhancement
    CLI
    windows-os
    subagent
    custom-model
    on Sep 24, 2026
  2. jamesruan0325-design commented on Sep 25, 2026

    @jamesruan0325-design

    Hey — I saw your Codex multi-provider setup and the idea of keeping the coordinator on Codex while routing high-volume subagent work through another OpenAI-compatible provider. I’m building BGYHub, a pay-as-you-go multi-model API gateway, and your workflow is almost exactly the kind of setup I’m trying to validate.

    If you’re interested, I can give you $3 test credit, no card required. I’d mainly be interested in whether the gateway works cleanly with your Codex custom-provider configuration and where compatibility breaks — not trying to replace your main Codex subscription.

  3. Ayoro commented on Nov 25, 2026

    @Ayoro

    Please let native v2 spawn_agent select a configured model_provider per child, either directly or through a custom role. Our use case is to keep the Codex Desktop parent signed in with ChatGPT while routing selected workers to a Responses-compatible gateway. The child should receive readable task messages and retain the native agent tree, completion notifications, and sandbox behavior.

  4. iqdoctor commented on Nov 27, 2026

    @iqdoctor

    +1, still present on codex-cli 0.172.0 (macOS).

    Concrete hybrid setup we are trying to use:

    • parent: gpt-6-luna via the OpenAI/ChatGPT session
    • subagent role: deepseek-flash via [model_providers.deepseek]
      • base_url = "https://api.deepseek.com/v1"
      • wire_api = "responses"
      • env_key = "DEEPSEEK_API_KEY"
    • another working custom Responses provider: Yandex AI Studio
      • base_url = "https://ai.api.cloud.yandex.net/v1"
      • wire_api = "responses"
      • env_key = "YANDEX_API_KEY"

    These providers currently work in separate CODEX_HOME profiles, but we want one native thread tree where the parent stays on Luna and selected workers use either DeepSeek or Yandex.

    This is not only a documentation gap. An agent-role TOML can contain model_provider because the role config is deserialized as ConfigToml, but the override path in codex-rs/core/src/agent/role.rs only forwards model, reasoning, instructions, personality, service tier, features, and skills. child_config.rs then sets the child provider from the parent turn, and tests explicitly assert that the child provider remains equal to the parent provider. As a result, model_provider in a role file is silently ineffective.

    Backward-compatible proposal:

    1. Add optional model_provider to spawn_agent arguments; default to the parent provider.
    2. Honor model_provider in standalone agent-role TOMLs and agents.<role>.config_file.
    3. Resolve it from [model_providers.<id>] in the active config.toml, including base_url, env_key/auth, and wire_api.
    4. Fail closed with a clear error when the requested provider is unavailable; never silently fall back to the parent provider.
    5. Preserve parent approval/sandbox authority, the native agent tree, completion notifications, and readable delegated task payloads for custom Responses providers.

    Related reports: #40858, #17598, #34833, #36387. The workaround of spawning a separate codex exec worker loses native subagent notifications and lifecycle management, so first-class support would be materially better.

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

    CLIcustom-modelenhancementsubagentwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions