-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: convert claude-4.5-sonnet to claude-sonnet-4-5 for Anthropic API #8380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Map internal model ID claude-4.5-sonnet to API-expected claude-sonnet-4-5 - Update createMessage to use original model ID for switch statements - Add test to verify correct model ID conversion - Fixes #8379
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review activated: a robot refactoring its own model IDs to avoid 404s while questioning the nature of strings.
|
|
||
| // Convert claude-4.5-sonnet to the format expected by Anthropic API | ||
| if (modelId === "claude-4.5-sonnet") { | ||
| modelId = "claude-sonnet-4-5" as any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Type safety. Avoid as any here—prefer a precise type to prevent future regressions.
| modelId = "claude-sonnet-4-5" as any | |
| modelId = "claude-sonnet-4-5" as AnthropicModelId |
| // Store the original model ID for switch statements | ||
| const originalModelId = modelId | ||
|
|
||
| // Convert claude-4.5-sonnet to the format expected by Anthropic API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The model ID conversion logic is duplicated here and in getModel(). Suggest extracting a helper (e.g., mapInternalToApiModelId(id)) and using it in both places to avoid drift.
| const model = handler.getModel() | ||
| expect(model.id).toBe("claude-4.5-sonnet") | ||
| // The model ID should be converted to the format expected by Anthropic API | ||
| expect(model.id).toBe("claude-sonnet-4-5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Good coverage for getModel() conversion. Consider adding a test that calls createMessage() with apiModelId: \"claude-4.5-sonnet\" and asserts the SDK is invoked with \"claude-sonnet-4-5\" (inspect the mock’s options.model).
| @@ -0,0 +1 @@ | |||
| Subproject commit e46929b8d8add0cd3c412d69f8ac882c405a4ba9 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Unintended submodule/gitlink (.review/pr-8274). Please remove from the PR to avoid committing tooling artifacts.
| @@ -0,0 +1 @@ | |||
| Subproject commit 88a473b017af37091c85ce3056e444e856f80d6e | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Unintended tracked artifact (tmp/pr-8287-Roo-Code). Please remove from the PR and consider ignoring tmp/ in .gitignore.


Description
This PR fixes issue #8379 where selecting Claude 4.5 Sonnet with the Anthropic provider results in a 404 error.
Problem
The Anthropic API expects the model ID to be
claude-sonnet-4-5, but Roo Code was sendingclaude-4.5-sonnet, causing a 404 error:Solution
AnthropicHandlerclass to map the internalclaude-4.5-sonnetID to the API-expectedclaude-sonnet-4-5formatChanges
createMessage()andgetModel()methodsTesting
Fixes #8379
Important
Fixes model ID format for Anthropic API by converting
claude-4.5-sonnettoclaude-sonnet-4-5inAnthropicHandler.claude-4.5-sonnettoclaude-sonnet-4-5inAnthropicHandlerto prevent 404 errors with Anthropic API.anthropic.spec.tsto verify model ID conversion.anthropic.ts: Implements model ID conversion increateMessage()andgetModel().anthropic.spec.ts: Adds test for model ID conversion.This description was created by
for 8154440. You can customize this summary. It will automatically update as commits are pushed.