Skip to content

fix(auxiliary): explicit_base_url path now respects api_mode=anthropic_messages - #17360

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/explicit-base-url-api-mode-anthropic
Closed

fix(auxiliary): explicit_base_url path now respects api_mode=anthropic_messages#17360
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/explicit-base-url-api-mode-anthropic

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

What changed and why

When resolve_provider_client() was called with both explicit_base_url and api_mode=anthropic_messages, the URL was silently mangled: _to_openai_base_url() rewrote any /anthropic suffix to /v1 before AnthropicAuxiliaryClient was constructed, so the Anthropic SDK hit the wrong endpoint surface (e.g. https://api.minimax.io/v1/messages instead of https://api.minimax.io/anthropic/messages).

PR #7648 fixed this for paths 1 (_try_custom_endpoint) and 2 (named custom providers). This PR fixes the remaining path 3 — the explicit_base_url branch — by adding an explicit early-return for api_mode=anthropic_messages that:

  1. Skips the /anthropic → /v1 URL rewrite (needed only for OpenAI-wire).
  2. Builds AnthropicAuxiliaryClient directly, matching the other two paths.
  3. Falls back gracefully to OpenAI-wire (with the rewritten URL) when the anthropic SDK is not installed.

Per the collaborator comment on #7661 (alt-glitch, 2026-04-29) mapping the three code paths.

How to test

pytest tests/agent/test_auxiliary_client_anthropic_custom.py -v

New tests:

  • test_explicit_base_url_anthropic_messages_builds_anthropic_wrapper — correct wrapper type returned
  • test_explicit_base_url_anthropic_messages_url_not_mangled/anthropic suffix preserved
  • test_explicit_base_url_anthropic_messages_falls_back_when_sdk_missing — graceful OpenAI-wire fallback
  • test_explicit_base_url_chat_completions_still_uses_openai_wire — regression: default path unchanged

What platforms tested on

macOS Darwin 24.6.0, Python 3.x

Fixes #7661

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps with #16256 — both fix path 3 (explicit_base_url) of #7661 for api_mode=anthropic_messages. Also related to superset fix #17152.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (4 upstream commits merged cleanly, no conflicts). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The remaining CI failures (test_anthropic_adapter.py, test_copilot_acp_client.py, and others) are in files this PR does not modify — they are pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from 4146264 to b71f52b Compare April 29, 2026 13:25
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (41 upstream commits, no conflicts). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The remaining CI failures are in files this PR does not modify (tests/hermes_cli/, tests/gateway/, tests/tools/, etc.) — pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from b71f52b to ab877e8 Compare April 29, 2026 17:35
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main. All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 5 failures in the full test suite (test_discord_reply_mode, test_discord_allowed_mentions, test_send_image_file, test_acp_server, test_platform_commands) are in files this PR does not modify and appear to be pre-existing upstream regressions (e.g. test_acp_server expects a command list that upstream feat(acp): add steer and queue slash commands since extended). The nix/nix-lockfile-check CI failures are also outside this PR's scope.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch 2 times, most recently from 0ab4838 to 2e3f475 Compare May 2, 2026 10:08
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (27 upstream commits, no conflicts). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 11 failures in the full CI suite are in files this PR does not modify (tests/acp/, tests/gateway/, tests/run_agent/, tests/hermes_cli/, tests/tools/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (1 upstream commit: docs(tts) — no conflicts). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 17 failures in the full CI suite are in files this PR does not modify (tests/acp/, tests/gateway/, tests/hermes_cli/, tests/tools/, tests/run_agent/, tests/plugins/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from 2e3f475 to 8cff874 Compare May 2, 2026 11:34
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (no new upstream commits since last update). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 17 failures in the full CI suite are all in files this PR does not modify (tests/acp/, tests/gateway/, tests/hermes_cli/, tests/tools/, tests/run_agent/, tests/plugins/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from 8cff874 to b6a9288 Compare May 2, 2026 16:01
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (no new upstream commits since last update). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 17 failures in the full CI suite are all in files this PR does not modify (tests/acp/, tests/gateway/, tests/hermes_cli/, tests/tools/, tests/run_agent/, tests/plugins/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch 2 times, most recently from b4590df to cc7500f Compare May 2, 2026 19:02
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (no new upstream commits since last update). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 17 failures in the full CI suite are all in files this PR does not modify (tests/acp/, tests/gateway/, tests/hermes_cli/, tests/tools/, tests/run_agent/, tests/plugins/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (already current — no new upstream commits since last update). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 16 failures in the full CI suite are all in files this PR does not modify (tests/acp/, tests/gateway/, tests/hermes_cli/, tests/tools/, tests/run_agent/, tests/plugins/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from cc7500f to 2681016 Compare May 3, 2026 03:17
@konsisumer

konsisumer commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (12 upstream commits, no conflicts). All 7 tests in tests/agent/test_auxiliary_client_anthropic_custom.py pass locally. The 16 failures in the full CI suite are all in files this PR does not modify (tests/acp/, tests/gateway/, tests/hermes_cli/, tests/tools/, tests/run_agent/, tests/plugins/, tests/test_tui_gateway_server.py) and are pre-existing upstream issues unrelated to this fix.

@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from 2681016 to be2f04b Compare May 3, 2026 06:03
@konsisumer
konsisumer force-pushed the fix/explicit-base-url-api-mode-anthropic branch from be2f04b to 62eb258 Compare May 3, 2026 08:57
@konsisumer

Copy link
Copy Markdown
Contributor Author

Closing — deferring to #16256 which addresses the same explicit_base_url/api_mode path. Reopen if that PR stalls.

@konsisumer konsisumer closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Custom auxiliary endpoints ignore api_mode: anthropic_messages

2 participants