Skip to content

fix(auxiliary): pass raw base_url to _maybe_wrap_anthropic for correct transport detection - #17467

Merged
teknium1 merged 3 commits into
NousResearch:mainfrom
chengoak:fix-kimi-coding-vision-404
Apr 30, 2026
Merged

fix(auxiliary): pass raw base_url to _maybe_wrap_anthropic for correct transport detection#17467
teknium1 merged 3 commits into
NousResearch:mainfrom
chengoak:fix-kimi-coding-vision-404

Conversation

@chengoak

Copy link
Copy Markdown
Contributor

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/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 → no Anthropic wrapping → 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 /v1 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)

Changes

In agent/auxiliary_client.py, 4 locations now preserve raw_base_url:

  1. _resolve_api_key_provider() — pool path
  2. _resolve_api_key_provider() — API key path
  3. resolve_provider_client() — named custom provider
  4. resolve_provider_client() — API-key providers

Test Plan

  • Verify title generation works with Kimi Coding provider
  • Verify auxiliary calls work with MiniMax provider
  • Ensure no regression for OpenAI-format providers

Related

Fixes the "⚠ Auxiliary title generation failed: HTTP 404" error reported when using api.kimi.com/coding or MiniMax as the auxiliary provider.

chengoak and others added 3 commits April 26, 2026 09:50
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.
@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 provider/minimax MiniMax (Anthropic transport) labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #17361 and #17387 — same root cause: _to_openai_base_url() rewrites URL before _maybe_wrap_anthropic() can detect Anthropic protocol, causing 404 on MiniMax/Kimi auxiliary calls.

@chengoak

Copy link
Copy Markdown
Contributor Author

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!

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #17361 and #17387 — same root cause.

@Austin5925

Copy link
Copy Markdown

Confirmed this fix is needed. Hit the same 404 on a fresh v0.11.0 install with MINIMAX_CN_BASE_URL=https://api.minimaxi.com/anthropic — every new session's title_generation throws Auxiliary title generation failed: HTTP 404: 404 page not found to the Telegram chat.

Verified locally with a hostname-whitelist hack on _to_openai_base_url (only skips the rewrite for api.minimaxi.com), but this PR's approach is the right architectural fix — passing the raw base_url through to _maybe_wrap_anthropic covers every Anthropic-protocol provider in one place instead of growing a host list. +1 to merge.

@teknium1
teknium1 merged commit 4e296dc into NousResearch:main Apr 30, 2026
donald131 pushed a commit to donald131/hermes-agent that referenced this pull request May 2, 2026
…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>
luyao618 added a commit to luyao618/hermes-agent that referenced this pull request May 5, 2026
…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
nickdlkk pushed a commit to nickdlkk/hermes-agent that referenced this pull request May 11, 2026
…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>
rousegordon-ops pushed a commit to rousegordon-ops/hermes-agent that referenced this pull request May 12, 2026
…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)
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…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>
jsboige pushed a commit to jsboige/hermes-agent that referenced this pull request May 14, 2026
…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>
dannyJ848 pushed a commit to dannyJ848/hermes-agent that referenced this pull request May 17, 2026
…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>
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…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>
Seven74AI pushed a commit to Seven74AI/hermes-agent that referenced this pull request Jun 13, 2026
…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>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…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>
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…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>
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 provider/minimax MiniMax (Anthropic transport) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants