Skip to content

fix(anthropic): honor custom apiModelId instead of silently defaulting to claude-sonnet-4-5#842

Open
grizmin wants to merge 3 commits into
Zoo-Code-Org:mainfrom
grizmin:fix/anthropic-custom-model-id-fallback
Open

fix(anthropic): honor custom apiModelId instead of silently defaulting to claude-sonnet-4-5#842
grizmin wants to merge 3 commits into
Zoo-Code-Org:mainfrom
grizmin:fix/anthropic-custom-model-id-fallback

Conversation

@grizmin

@grizmin grizmin commented Jul 6, 2026

Copy link
Copy Markdown

Summary

  • AnthropicHandler.getModel() coerced any apiModelId not present in the static anthropicModels table down to anthropicDefaultModelId ("claude-sonnet-4-5") — and that coerced id is what actually got sent as model in the API request, silently ignoring a user-configured custom model name.
  • The same fallback broke capability lookups used to build the thinking request param: an unrecognized id inherited the default model's (older) capability profile, so custom deployments of newer models (e.g. Sonnet 5 class) got the legacy thinking: {type: "enabled", budget_tokens} shape instead of {type: "adaptive"}, which those models reject with a 400.
  • Fix: the model id sent to the API always honors a user-configured apiModelId. For unrecognized values, capabilities are best-effort guessed via known model-family substring matching (same pattern as the existing BedrockHandler.guessModelInfoFromId).

Fixes #418
Fixes #843

Test plan

  • Added regression tests in anthropic.spec.ts covering: custom model id preserved in getModel().id, capability guessing via substring match, fallback to default info when no family matches, and createMessage sending the raw custom id with thinking: {type: "adaptive"}.
  • pnpm --filter zoo-code test - 50/50 passing
  • pnpm --filter zoo-code check-types - clean
  • pnpm --filter zoo-code lint - clean

grizmin added 3 commits July 6, 2026 15:06
…g to claude-sonnet-4-5

Unrecognized model IDs were coerced to the hardcoded default before being sent to the API and for capability lookups, breaking custom deployments and picking the wrong thinking config.

Fixes Zoo-Code-Org#418
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

1 participant