fix: exclude anthropic prefix from Bedrock detection to avoid false positives

This commit is contained in:
Roo Code 2025-12-20 22:23:42 +00:00
parent 157146aff2
commit bbd325f539
2 changed files with 10 additions and 9 deletions

View file

@ -402,11 +402,7 @@ describe("LiteLLMHandler", () => {
describe("Bedrock model handling", () => {
it("should exclude parallel_tool_calls for Bedrock models when using native tools", async () => {
const bedrockModels = [
"bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0",
"anthropic.claude-sonnet-4-20250514-v1:0",
"amazon.titan-text-express-v1",
]
const bedrockModels = ["bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0", "amazon.titan-text-express-v1"]
for (const modelId of bedrockModels) {
vi.clearAllMocks()
@ -466,7 +462,12 @@ describe("LiteLLMHandler", () => {
})
it("should include parallel_tool_calls for non-Bedrock models when using native tools", async () => {
const nonBedrockModels = ["gpt-4", "claude-3-opus", "gpt-4-turbo"]
const nonBedrockModels = [
"gpt-4",
"claude-3-opus",
"gpt-4-turbo",
"anthropic.claude-sonnet-4-20250514-v1:0",
]
for (const modelId of nonBedrockModels) {
vi.clearAllMocks()

View file

@ -41,15 +41,15 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa
/**
* Check if the model is routed through AWS Bedrock
* Bedrock doesn't support the parallel_tool_calls parameter
* Note: We exclude 'anthropic.' prefix as it can match direct Anthropic API access through LiteLLM
*/
private isBedrockModel(modelId: string): boolean {
const lowerModel = modelId.toLowerCase()
return (
lowerModel.includes("bedrock") ||
lowerModel.startsWith("anthropic.") ||
lowerModel.includes("amazon.") ||
// Match AWS Bedrock model ID patterns
/^(anthropic|amazon|ai21|cohere|meta|mistral)\./.test(lowerModel)
// Match AWS Bedrock model ID patterns (excluding anthropic to avoid false positives)
/^(amazon|ai21|cohere|meta|mistral)\./.test(lowerModel)
)
}