Skip to content

fix(delegation): use 'custom' provider when base_url is set without explicit provider#12941

Open
asphyksia wants to merge 1 commit into
NousResearch:mainfrom
asphyksia:fix/subagent-provider-custom-endpoint
Open

fix(delegation): use 'custom' provider when base_url is set without explicit provider#12941
asphyksia wants to merge 1 commit into
NousResearch:mainfrom
asphyksia:fix/subagent-provider-custom-endpoint

Conversation

@asphyksia

Copy link
Copy Markdown
    ## Summary

    When a subagent is configured with a custom `base_url` but no explicit `provider`, it should use `'custom'` as the provider rather than inheriting the parent's provider. This fixes credential resolution for subagents using custom endpoints like NVIDIA NIM.

    ## Problem

    The current code in `_build_child_agent()` always inherits the parent's provider when `override_provider` is not set:

    ```python
    effective_provider = override_provider or getattr(parent_agent, "provider", None)
    ```

    This causes issues when:
    1. Parent uses provider `alibaba` with model `kimi-k2.5`
    2. Subagent is configured with `base_url=https://integrate.api.nvidia.com/v1` and `model=nvidia/minimaxai/minimax-m2.7`
    3. Subagent inherits `provider=alibaba` from parent
    4. The wrong API endpoint and auth headers are used for the subagent

    ## Solution

    When `override_base_url` is explicitly set (indicating a custom endpoint), use `"custom"` as the default provider instead of inheriting from parent:

    ```python
    if override_base_url:
        # Custom endpoint configured - use override values or defaults
        effective_provider = override_provider or "custom"
        ...
    else:
        # No custom endpoint - inherit from parent
        effective_provider = override_provider or getattr(parent_agent, "provider", None)
    ```

    ## Additional Fix

    Also updates `_load_config()` to always read fresh from `config.yaml` instead of using the potentially stale `CLI_CONFIG` cache. This ensures delegation config changes are picked up without restarting the CLI (fixes issue #11999).

    The previous implementation short-circuited through `cli.CLI_CONFIG` which is populated once at module-import time and never re-read, causing config changes to be silently ignored in long-lived CLI sessions.

    ## Testing

    Tested with:
    - Parent: `kimi-k2.5` via DashScope (provider: `alibaba`)
    - Subagent: `nvidia/minimaxai/minimax-m2.7` via NVIDIA NIM

    Subagent now correctly uses `provider="custom"` with the NVIDIA endpoint instead of inheriting `provider="alibaba"` from the parent.

    ## Related Issues/PRs

    - Complements PR #12053 (config loading improvements)
    - Fixes credential resolution for custom endpoints in subagents
    - Addresses layer of issue #11999 (stale config in long-lived sessions)

    ## Checklist

    - [x] Code follows project style guidelines
    - [x] Changes are backward compatible
    - [x] Tested with real provider configurations
    - [x] Documentation/comments updated
    ```

…xplicit provider

When a subagent is configured with a custom base_url but no explicit
provider, it should use 'custom' as the provider rather than inheriting
the parent's provider. This fixes credential resolution for subagents
using custom endpoints like NVIDIA NIM.

Also fixes _load_config() to always read fresh from config.yaml instead
of using the stale CLI_CONFIG cache. This ensures delegation config
changes are picked up without restarting the CLI.

Fixes subagent credential resolution when using custom base_url without
explicit provider (complements PR NousResearch#12053).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants