Skip to content

fix(auxiliary): keep /anthropic base_url for anthropic_messages custom endpoints (salvage #64891) - #85466

Merged
teknium1 merged 1 commit into
mainfrom
salv-64891
Aug 13, 2026
Merged

fix(auxiliary): keep /anthropic base_url for anthropic_messages custom endpoints (salvage #64891)#85466
teknium1 merged 1 commit into
mainfrom
salv-64891

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Auxiliary tasks (titles, compression, vision) work again on custom providers whose base_url ends in /anthropic (MiniMax, Zhipu, LiteLLM proxies). Salvage of #64891 by @AlexanderPrendota onto current main, authorship preserved. Fixes #16254 (dup #17086).

Root cause: the explicit-base branch of resolve_provider_client() rewrote /anthropic/v1 unconditionally before the Anthropic-wrap decision, so the Messages wrapper was built against a /v1 URL and every auxiliary call 404'd.

Changes

  • agent/auxiliary_client.py: when api_mode == "anthropic_messages", _wrap_if_needed gets the raw /anthropic base; the plain-OpenAI client and SDK-unavailable fallback keep the /v1-rewritten base — same guard the named-custom-provider branch already has
  • tests/agent/test_auxiliary_explicit_base_anthropic.py: 3 regression tests (wrapper keeps /anthropic, fallback stays /v1, non-anthropic rewrite preserved)

Validation

Before After
aux calls vs Messages-only gateway 404 on /v1/chat/completions wrapped on real endpoint
OpenAI-mode custom base /v1 rewrite unchanged
targeted tests 3/3 pass

Sibling paths (#60753 vision, #61333 class-wide guard) tracked as a separate cluster decision.

Infographic

Auxiliary anthropic base_url fix

…m endpoints

The custom + explicit_base_url branch of resolve_provider_client()
unconditionally rewrote a trailing /anthropic to /v1 via
_to_openai_base_url(), even when api_mode was anthropic_messages. The
Anthropic wrapper then never saw the real /anthropic path, so auxiliary
tasks (title generation, compression, vision, web_extract,
session_search) hit .../v1/chat/completions on a Messages-only endpoint
and failed.

Guard the wrap base on api_mode: for anthropic_messages, pass the raw
/anthropic base to _wrap_if_needed (which builds the Anthropic wrapper),
while the plain OpenAI client keeps the /v1-rewritten base so the
OpenAI-wire fallback (used when the anthropic SDK is unavailable) never
lands on /anthropic/chat/completions.

Refs #16254
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 5ecaf92 — fix(auxiliary): keep /anthropic base_url for anthropic_messa

⚠️ Warnings

OSV vulnerability scan · View job

5 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 4m35s vs 7m10s (-36.0%). 12 job(s) slower, 9 faster, 3 unchanged.

  • Python tests / Run tests slice 5/12: +42.0s
  • Python tests / Run tests slice 4/12: -38.0s
  • Python tests / Run tests slice 1/12: +29.0s
  • Python tests / Run tests slice 7/12: +28.0s
  • Python tests / Run tests slice 3/12: -15.0s

@teknium1
teknium1 merged commit 3cf8293 into main Aug 13, 2026
45 checks passed
@teknium1
teknium1 deleted the salv-64891 branch August 13, 2026 17:32
@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
teknium1 pushed a commit that referenced this pull request Aug 13, 2026
Fallback activation determined api_mode from the POST-rewrite client
base_url, losing the Anthropic wire signal for /anthropic endpoints
routed through provider 'custom', and never honored an explicit
fb.api_mode config field. Pre-compute fb_api_mode from the ORIGINAL
fallback base_url hint (before _to_openai_base_url rewriting), honor
the explicit api_mode config field, check provider name before the
base_url gate, and pass api_mode into resolve_provider_client at the
fallback call site.

Salvaged from PR #79787 (chat_completion_helpers.py hunks; the
auxiliary_client.py hunk is redundant with #85466's wrap_base fix).
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

3 participants