Skip to content

fix(aux): honor explicit base_url for named providers; preserve /anthropic - #17152

Closed
wmagev wants to merge 1 commit into
NousResearch:mainfrom
wmagev:fix/cluster-13-aux-client-config-inheritance
Closed

fix(aux): honor explicit base_url for named providers; preserve /anthropic#17152
wmagev wants to merge 1 commit into
NousResearch:mainfrom
wmagev:fix/cluster-13-aux-client-config-inheritance

Conversation

@wmagev

@wmagev wmagev commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Three related config-inheritance bugs in agent/auxiliary_client.py that
surface when the auxiliary client (compression, title generation, vision,
session search, etc.) tries to reuse the user's main provider config:

  1. _resolve_auto only forwarded base_url for custom / custom:*
    providers (Auxiliary tasks (compression, title generation) ignore custom base_url for named providers #16719).
    With provider: zai + base_url: <override>, the
    override was silently dropped and auxiliary traffic went to z.ai's
    default endpoint. Now forwarded as explicit_base_url /
    explicit_api_key for any named provider.

  2. PROVIDER_REGISTRY branch ignored explicit_base_url / explicit_api_key.
    Even after fix (1), the named-provider branch unconditionally pulled
    base_url from creds["base_url"] or pconfig.inference_base_url. Now
    prefers the forwarded explicit values.

  3. custom branch unconditionally rewrote /anthropic/v1 (Bug: auxiliary tasks fail with HTTP 404 when using anthropic_messages custom endpoint — URL rewrite strips /anthropic/ path #17086).
    _to_openai_base_url() is the right normalization for OpenAI-wire
    gateways, but for api_mode: anthropic_messages (or any URL the
    _endpoint_speaks_anthropic_messages() heuristic recognizes) the
    rewrite breaks the AnthropicAuxiliaryClient — requests land on
    /v1/chat/completions instead of /anthropic/v1/messages → 404 on
    every aux task. The same guard already existed in
    _try_custom_endpoint() and the named-custom-provider branch; this PR
    extends it to the explicit_base_url custom branch and the
    PROVIDER_REGISTRY branch.

Out of scope (mentioned in the original issues but separately resolved):

Test plan

  • tests/agent/test_auxiliary_named_custom_providers.py — 31 passed
    (3 new test classes, 5 new tests)
  • tests/agent/test_auxiliary_client.py — 194 sync tests pass; 5
    pre-existing async failures unrelated (require pytest-asyncio)
  • tests/agent/test_auxiliary_client_anthropic_custom.py — passes
    (existing _try_custom_endpoint anthropic_messages coverage)
  • tests/agent/test_auxiliary_main_first.py,
    test_auxiliary_transport_autodetect.py,
    test_minimax_auxiliary_url.py,
    test_auxiliary_config_bridge.py — all pass
  • tests/agent/test_context_compressor.py — 65 passed (no compression
    regressions)
  • Manual: configure provider: zai + base_url: https://custom-zai.example.com/v1 and verify compression hits the
    custom URL (logs show Auxiliary auto-detect: using main provider zai
    and the request goes to the override).
  • Manual: configure custom Anthropic-compat proxy with api_mode: anthropic_messages + base_url: http://localhost:6655/anthropic/
    and verify auxiliary tasks no longer 404.

Closes: #16719, #17086

…ropic

Three config-inheritance bugs in agent/auxiliary_client.py that surface
when the auxiliary client (compression, title-gen, vision, etc.) tries to
reuse the user's main provider config:

1. _resolve_auto only forwarded base_url for "custom" / "custom:*"
   providers (NousResearch#16719). For provider=zai + base_url=<override>, the
   override was silently dropped → aux traffic went to z.ai's default
   endpoint. Forward as explicit_base_url / explicit_api_key for any
   named provider.

2. PROVIDER_REGISTRY branch ignored explicit_base_url / explicit_api_key
   even when forwarded. Now prefers them over creds["base_url"] /
   pconfig.inference_base_url.

3. custom branch unconditionally rewrote /anthropic → /v1 (NousResearch#17086).
   For api_mode=anthropic_messages (or URL recognized by
   _endpoint_speaks_anthropic_messages), the rewrite makes
   AnthropicAuxiliaryClient hit /v1/chat/completions instead of
   /anthropic/v1/messages → 404 on every aux task. Same guard already
   existed in _try_custom_endpoint() and the named-custom branch;
   extend it to the explicit-custom and PROVIDER_REGISTRY branches.

Closes: NousResearch#16719, NousResearch#17086
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/config Config system, migrations, profiles labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #16256 / #16254 — overlapping fixes for auxiliary_client.py explicit_base_url and api_mode handling. This PR appears to be a superset that addresses all three bugs (base_url forwarding, PROVIDER_REGISTRY ignoring explicit values, /anthropic rewrite).

@teknium1

Copy link
Copy Markdown
Contributor

Closing — the /anthropic URL rewrite portion is now fixed by #17467 (merged as 4e296dc) via a more localized approach (preserve raw URL for transport detection). Your other two fixes — _resolve_auto forwarding base_url for named providers (#16719) and the PROVIDER_REGISTRY branch honoring explicit_base_url/explicit_api_key — are still valuable and not covered by #17467. Please re-scope to just those two fixes in a fresh PR and I'll review.

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

Labels

area/config Config system, migrations, profiles comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auxiliary tasks (compression, title generation) ignore custom base_url for named providers

3 participants