-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: exclude parallel_tool_calls for Bedrock models in LiteLLM #10235
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,30 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa | |
| return /\bgpt-?5(?!\d)/i.test(modelId) | ||
| } | ||
|
|
||
| /** | ||
| * Check if the model is routed through AWS Bedrock | ||
| * Bedrock doesn't support the parallel_tool_calls parameter | ||
| * | ||
| * If the user has explicitly set litellmUseAzureBedrock, use that setting. | ||
| * Otherwise, fall back to auto-detection based on model ID patterns. | ||
| * Note: We exclude 'anthropic.' prefix as it can match direct Anthropic API access through LiteLLM | ||
| */ | ||
| private isBedrockModel(modelId: string): boolean { | ||
|
Collaborator
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. This doesn’t seem right
Contributor
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. @roomote address this
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.
This issue was already addressed in commit bbd325f. The |
||
| // User-specified option takes precedence | ||
| if (this.options.litellmUseAzureBedrock !== undefined) { | ||
| return this.options.litellmUseAzureBedrock | ||
| } | ||
|
|
||
| // Fall back to auto-detection | ||
| const lowerModel = modelId.toLowerCase() | ||
| return ( | ||
| lowerModel.includes("bedrock") || | ||
| lowerModel.includes("amazon.") || | ||
| // Match AWS Bedrock model ID patterns (excluding anthropic to avoid false positives) | ||
| /^(amazon|ai21|cohere|meta|mistral)\./.test(lowerModel) | ||
| ) | ||
| } | ||
|
|
||
| override async *createMessage( | ||
| systemPrompt: string, | ||
| messages: Anthropic.Messages.MessageParam[], | ||
|
|
@@ -133,7 +157,9 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa | |
| }, | ||
| ...(useNativeTools && { tools: this.convertToolsForOpenAI(metadata.tools) }), | ||
| ...(useNativeTools && metadata.tool_choice && { tool_choice: metadata.tool_choice }), | ||
| ...(useNativeTools && { parallel_tool_calls: metadata?.parallelToolCalls ?? false }), | ||
| // Bedrock doesn't support parallel_tool_calls parameter, so exclude it for Bedrock models | ||
| ...(useNativeTools && | ||
| !this.isBedrockModel(modelId) && { parallel_tool_calls: metadata?.parallelToolCalls ?? false }), | ||
| } | ||
|
|
||
| // GPT-5 models require max_completion_tokens instead of the deprecated max_tokens parameter | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -370,6 +370,8 @@ | |
| "getXaiApiKey": "Get xAI API Key", | ||
| "litellmApiKey": "LiteLLM API Key", | ||
| "litellmBaseUrl": "LiteLLM Base URL", | ||
| "litellmUseAzureBedrock": "Backend is AWS Bedrock", | ||
|
Contributor
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. Typographical note: The key |
||
| "litellmUseAzureBedrockDescription": "Enable this if your LiteLLM proxy routes to AWS Bedrock models. This ensures Bedrock-incompatible parameters are excluded from requests.", | ||
| "awsCredentials": "AWS Credentials", | ||
| "awsProfile": "AWS Profile", | ||
| "awsApiKey": "Amazon Bedrock API Key", | ||
|
|
||
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.
Naming inconsistency: The property is named
litellmUseAzureBedrockbut it configures AWS Bedrock (Amazon), not Azure (Microsoft). This conflation of cloud providers in the variable name could confuse developers. Consider renaming tolitellmUseAwsBedrockorlitellmUseBedrockto match the actual functionality.Fix it with Roo Code or mention @roomote and request a fix.