forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: improve Bedrock Claude 4.5 model detection for custom ARNs #8562
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,47 +254,112 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH | |
| // Helper to guess model info from custom modelId string if not in bedrockModels | ||
| private guessModelInfoFromId(modelId: string): Partial<ModelInfo> { | ||
| // Define a mapping for model ID patterns and their configurations | ||
| // Order matters - more specific patterns should come first | ||
| const modelConfigMap: Record<string, Partial<ModelInfo>> = { | ||
| "claude-4": { | ||
| // Claude 4.5 Sonnet (most specific) | ||
| "claude-sonnet-4-5": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| "claude-3-7": { | ||
| // Claude 4 Sonnet | ||
| "claude-sonnet-4": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| "claude-3-5": { | ||
| // Claude 4 Opus | ||
| "claude-opus-4": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| "claude-4-opus": { | ||
| maxTokens: 4096, | ||
| // Claude 3.7 Sonnet | ||
| "claude-3-7-sonnet": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| // Claude 3.5 Sonnet | ||
| "claude-3-5-sonnet": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| }, | ||
| // Claude 3.5 Haiku | ||
| "claude-3-5-haiku": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: false, | ||
| supportsPromptCache: true, | ||
| }, | ||
| // Claude 3 Opus | ||
| "claude-3-opus": { | ||
| maxTokens: 4096, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsPromptCache: false, | ||
| }, | ||
| // Claude 3 Sonnet | ||
| "claude-3-sonnet": { | ||
| maxTokens: 4096, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: false, | ||
| }, | ||
| // Claude 3 Haiku | ||
| "claude-3-haiku": { | ||
| maxTokens: 4096, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: false, | ||
| }, | ||
| // Generic Claude 4 (fallback for any Claude 4 variant) | ||
| "claude-4": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| // Generic Claude 3.7 | ||
| "claude-3-7": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| // Generic Claude 3.5 | ||
| "claude-3-5": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| }, | ||
| } | ||
|
|
||
| // Match the model ID to a configuration | ||
| const id = modelId.toLowerCase() | ||
|
|
||
| // Check patterns in order (more specific first) | ||
| for (const [pattern, config] of Object.entries(modelConfigMap)) { | ||
| if (id.includes(pattern)) { | ||
| return config | ||
|
|
@@ -885,6 +950,24 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH | |
| } | ||
| } | ||
|
|
||
| // Also handle additional regional prefixes that might not be in the mapping | ||
| // These are commonly used in cross-region inference IDs | ||
| const additionalRegionalPrefixes = [ | ||
| "au.", // Australia (e.g., au.anthropic.claude-sonnet-4-5-20250929-v1:0) | ||
| "af.", // Africa | ||
| "me.", // Middle East | ||
| "il.", // Israel | ||
| "cn.", // China | ||
| "jp.", // Japan (alternative to ap-) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Unverified regional prefix 'jp.' may not be a documented AWS inference profile prefix; stripping it could inadvertently mangle legitimate model IDs. Recommend relying on AWS_INFERENCE_PROFILE_MAPPING or adding tests/docs reference before introducing new prefixes. |
||
| ] | ||
|
|
||
| for (const prefix of additionalRegionalPrefixes) { | ||
| if (modelId.startsWith(prefix)) { | ||
| // Remove the regional prefix from the model ID | ||
| return modelId.substring(prefix.length) | ||
| } | ||
| } | ||
|
|
||
| // Return the model ID as-is for all other cases | ||
| return modelId | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: Pattern typo prevents detection of Claude 4 Opus; Anthropic naming uses 'claude-4-opus'. This key won't match real IDs like '...claude-4-opus-...'.