Skip to content

fix(agent): wrap auxiliary clients using explicit_base_url - #85597

Closed
686f6c61 wants to merge 1 commit into
NousResearch:mainfrom
686f6c61:fix/85535-wrap-explicit-base-url
Closed

fix(agent): wrap auxiliary clients using explicit_base_url#85597
686f6c61 wants to merge 1 commit into
NousResearch:mainfrom
686f6c61:fix/85535-wrap-explicit-base-url

Conversation

@686f6c61

@686f6c61 686f6c61 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What breaks

A fallback / auxiliary entry that names a built-in API-key provider (e.g. minimax) but overrides explicit_base_url to an Anthropic-only gateway never gets AnthropicAuxiliaryClient. Side tasks (title, compression, vision) keep talking OpenAI /chat/completions at the stock provider host, not the override.

This is the leftover call site from the August /anthropic/v1 sweep. #85532 / #85466 cover the rewrite policy; they do not fix which URL wrap inspects.

Why

In resolve_provider_client()’s auth_type == "api_key" branch:

  1. The OpenAI client is built with base_url = _to_openai_base_url(explicit or creds).
  2. _wrap_if_needed(...) was passed raw_base_url.

If wrap does not see the override (or sees the pool’s MiniMax/OpenAI stock URL), _maybe_wrap_anthropic never matches /anthropic / api_mode=anthropic_messages for the URL the user actually targeted.

What this changes

When explicit_base_url is set, wrap receives that string un-rewritten (so an /anthropic suffix stays visible). Otherwise it still uses the credential base.

The client construction / _to_openai_base_url host allowlist is unchanged. Dual-surface MiniMax still rewrites the OpenAI client to /v1; wrap still needs the raw override to decide Messages vs chat.

Verify

pytest tests/agent/test_auxiliary_explicit_base_anthropic.py::test_api_key_provider_wrap_uses_explicit_override_not_stock_creds_url
# 1 passed

Stock creds mocked as MiniMax /v1; explicit base is an Anthropic-only proxy. Asserts AnthropicAuxiliaryClient and build_anthropic_client(..., override_url).

Fixes #85535

The API-key branch built the OpenAI client on the override URL but
passed the credential-pool stock base into _wrap_if_needed, so
Anthropic-wire fallbacks never wrapped.

Fixes NousResearch#85535
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 13, 2026
@spfcraze

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Summary:
The bug #85535 describes is already fixed on current main — agent/auxiliary_client.py:6622 assigns raw_base_url = explicit_base_url... before the wrap call at :6720, so this change is a no-op.

Problems:

  • On current main, the api_key branch reassigns raw_base_url = explicit_base_url.strip().rstrip("/") at agent/auxiliary_client.py:6622 whenever an override is present, and the existing wrap call at :6720 passes raw_base_url — the wrap already inspects the override, so the premise of [Bug] API-key branch: _wrap_if_needed receives creds raw_base_url instead of the explicit_base_url override — wrap decision uses wrong URL #85535 does not hold on main.
  • The new wrap_url evaluates to the identical value in both branches: with explicit_base_url set it is explicit_base_url.strip().rstrip("/"), the string line 6622 already assigned to raw_base_url; otherwise it is raw_base_url itself. The change is behaviorally identical to the line it replaces.
  • The added test asserts the behavior line 6622 already guarantees on main, so the diff does not alter what the test observes.

Solution:
Confirm against current main that raw_base_url is already the explicit override at agent/auxiliary_client.py:6622 before the wrap call at :6720; if so, the change is behaviorally identical to current main and the issue is already resolved there.

Evidence

no deterministic fact backs this claim — model belief, not executed or read evidence


Checked against d1e59a2 — the tip of fix/85535-wrap-explicit-base-url when this was written — and a364390, main at the same moment.

@686f6c61

Copy link
Copy Markdown
Contributor Author

Checked current main (origin/main as of this comment): the api_key branch already does

if explicit_base_url:
    raw_base_url = explicit_base_url.strip().rstrip("/")

at agent/auxiliary_client.py:6622 before _wrap_if_needed(..., raw_base_url, ...) at :6720. The wrap_url ternary here is the same string, so this PR does not change behavior.

Closing as already fixed on main. The added test is also redundant with that assignment — not worth landing on its own.

@686f6c61

Copy link
Copy Markdown
Contributor Author

Closing: wrap already sees the explicit override on main (see previous comment).

@686f6c61 686f6c61 closed this Aug 14, 2026
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 P3 Low — cosmetic, nice to have provider/anthropic Anthropic native Messages API sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] API-key branch: _wrap_if_needed receives creds raw_base_url instead of the explicit_base_url override — wrap decision uses wrong URL

3 participants