fix(auxiliary): pass raw base_url to _maybe_wrap_anthropic for correct transport detection - #17467
Conversation
Kimi Code base URL is https://api.kimi.com/coding (without /v1): - Anthropic SDK auto-appends /v1/messages → works fine - OpenAI SDK auto-appends /chat/completions → hits /coding/chat/completions which 404s Add Kimi-specific handling to _to_openai_base_url() to append /v1, similar to the existing MiniMax /anthropic → /v1 conversion. Fixes vision_analyze tool returning 404 when using kimi-coding provider.
…t transport detection The _to_openai_base_url() function rewrites Anthropic-style URLs to OpenAI-compatible format (e.g., /anthropic -> /v1, /coding -> /coding/v1). However, _maybe_wrap_anthropic() needs the ORIGINAL URL to correctly detect whether the endpoint speaks Anthropic Messages protocol via _endpoint_speaks_anthropic_messages(). Before this fix: - MiniMax: /anthropic rewritten to /v1, then _endpoint_speaks_anthropic_messages(/v1) returned False, so no Anthropic wrapping occurred -> 404 on /v1/chat/completions - Kimi Coding: /coding rewritten to /coding/v1, but _endpoint_speaks_anthropic_messages still matched due to '/coding' in URL, causing double-wrapping confusion After this fix: - OpenAI client uses the rewritten URL (correct for chat.completions) - _maybe_wrap_anthropic uses the raw URL for transport detection (correct for protocol selection) Fixes transport mismatch for MiniMax, Kimi Coding, and other Anthropic-compatible providers.
|
Hi @teknium1, this PR complements #17451 (which skipped kimi-coding in vision auto-detect). This fix addresses the root cause: was rewriting Anthropic URLs before could detect the transport protocol, causing 404s for both Kimi Coding and MiniMax auxiliary clients. The fix preserves the raw base_url for transport detection while still using the rewritten URL for OpenAI client creation — a more general solution than per-provider special-casing. Would appreciate a review when you have a moment. Thanks! |
|
Confirmed this fix is needed. Hit the same 404 on a fresh v0.11.0 install with Verified locally with a hostname-whitelist hack on |
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…hropic transport The explicit_base_url branch in resolve_provider_client() was passing custom_base (_to_openai_base_url()-rewritten URL with /v1 appended) to _wrap_if_needed(). When _maybe_wrap_anthropic() forwarded this to build_anthropic_client(), the Anthropic SDK appended its own /v1/messages, producing a double /v1/v1/messages path — HTTP 404. PR NousResearch#17467 fixed the same class of bug for the named-custom-provider and _try_custom_endpoint branches, but missed the explicit_base_url branch (line ~2206). Fix: pass explicit_base_url (the raw, un-rewritten URL) so the Anthropic SDK constructs the correct /v1/messages path. Fixes NousResearch#19753
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com> (cherry picked from commit 4e296dc)
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
…t transport detection (NousResearch#17467) Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax, MiniMax-CN) for auxiliary tasks. Root cause: `_to_openai_base_url()` rewrites `/anthropic` → `/v1` so the OpenAI SDK hits the right endpoint. But the rewritten URL was then passed to `_maybe_wrap_anthropic`, whose `_endpoint_speaks_anthropic_messages` detector only fires on `/anthropic` or `api.kimi.com/coding`. Detector saw `/v1` → returned False → no Anthropic wrap → 404 on every aux call. Fix: preserve the raw base_url before rewriting and pass it to `_maybe_wrap_anthropic` for transport detection, while still giving the rewritten URL to the OpenAI client constructor. Closes NousResearch#17705, NousResearch#17413, NousResearch#17086, NousResearch#10469. Co-authored-by: oak <chengoak@users.noreply.github.com>
Summary
Fixes HTTP 404 errors when using Anthropic-compatible providers (Kimi Coding, MiniMax) for auxiliary tasks (title generation, etc.).
Root Cause
_to_openai_base_url()rewrites Anthropic-protocol URLs to OpenAI-compatible format:/anthropic→/v1/coding→/coding/v1However,
_maybe_wrap_anthropic()needs the original URL to correctly detect whether the endpoint speaks Anthropic Messages protocol via_endpoint_speaks_anthropic_messages().Before this fix:
/anthropicrewritten to/v1, then_endpoint_speaks_anthropic_messages(/v1)returnedFalse→ no Anthropic wrapping → 404 on/v1/chat/completions/codingrewritten to/coding/v1, but_endpoint_speaks_anthropic_messagesstill matched due to/codingin URL, causing double/v1confusionAfter this fix:
chat.completions)_maybe_wrap_anthropicuses the raw URL for transport detection (correct for protocol selection)Changes
In
agent/auxiliary_client.py, 4 locations now preserveraw_base_url:_resolve_api_key_provider()— pool path_resolve_api_key_provider()— API key pathresolve_provider_client()— named custom providerresolve_provider_client()— API-key providersTest Plan
Related
Fixes the "⚠ Auxiliary title generation failed: HTTP 404" error reported when using
api.kimi.com/codingor MiniMax as the auxiliary provider.