Skip to content

fix(anthropic): resolve model aliases for anthropic_native provider#204

Merged
viettranx merged 1 commit intonextlevelbuilder:mainfrom
xuandung38:main
Mar 15, 2026
Merged

fix(anthropic): resolve model aliases for anthropic_native provider#204
viettranx merged 1 commit intonextlevelbuilder:mainfrom
xuandung38:main

Conversation

@xuandung38
Copy link
Contributor

Problem

When an agent is configured with a short model alias (e.g. "opus", "sonnet", "haiku") and uses the anthropic_native provider, the alias is sent verbatim to the Anthropic API, resulting in a HTTP 404 not_found_error:

LLM call failed (iteration 1): HTTP 404: anthropic: {"type":"error","error":{"type":"not_found_error","message":"model: opus"}}

Short aliases are only valid for the Claude CLI provider, which handles them internally. The AnthropicProvider lacked equivalent resolution.

Solution

Added resolveAnthropicModel() in internal/providers/anthropic.go — a small helper that expands short aliases to full Anthropic model IDs before the API call. Both Chat() and ChatStream() now go through this resolver.

Alias map:

Alias Resolved model ID
opus claude-opus-4-6
sonnet claude-sonnet-4-6
haiku claude-haiku-4-5-20251001

Full model IDs (e.g. claude-sonnet-4-5-20250929) are passed through unchanged — no breaking change.

Files changed

  • internal/providers/anthropic.go — added claudeModelAliases map + resolveAnthropicModel(), updated Chat()
  • internal/providers/anthropic_stream.go — updated ChatStream() to use the resolver

@viettranx viettranx merged commit 23eb42a into nextlevelbuilder:main Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants