mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: move anthropic_beta back to top level for AWS Bedrock 1M context
Fixes #7085 - "invalid beta flag" error when using 1M context with Claude Sonnet 4 The anthropic_beta parameter needs to be at the top level of the Bedrock payload, not inside additionalModelRequestFields. This reverts the incorrect placement introduced in PR #7056 while keeping the other improvements from that PR.
This commit is contained in:
parent
dcbb7a673f
commit
ed6bf41de3
2 changed files with 14 additions and 19 deletions
|
|
@ -635,11 +635,10 @@ describe("AwsBedrockHandler", () => {
|
|||
expect(mockConverseStreamCommand).toHaveBeenCalled()
|
||||
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any
|
||||
|
||||
// Should include anthropic_beta in additionalModelRequestFields
|
||||
expect(commandArg.additionalModelRequestFields).toBeDefined()
|
||||
expect(commandArg.additionalModelRequestFields.anthropic_beta).toEqual(["context-1m-2025-08-07"])
|
||||
// Should include anthropic_beta at top level of payload
|
||||
expect(commandArg.anthropic_beta).toEqual(["context-1m-2025-08-07"])
|
||||
// Should not include anthropic_version since thinking is not enabled
|
||||
expect(commandArg.additionalModelRequestFields.anthropic_version).toBeUndefined()
|
||||
expect(commandArg.anthropic_version).toBeUndefined()
|
||||
})
|
||||
|
||||
it("should not include anthropic_beta parameter when 1M context is disabled", async () => {
|
||||
|
|
@ -665,7 +664,9 @@ describe("AwsBedrockHandler", () => {
|
|||
expect(mockConverseStreamCommand).toHaveBeenCalled()
|
||||
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any
|
||||
|
||||
// Should not include anthropic_beta in additionalModelRequestFields
|
||||
// Should not include anthropic_beta at top level
|
||||
expect(commandArg.anthropic_beta).toBeUndefined()
|
||||
// Should not include additionalModelRequestFields when no thinking is enabled
|
||||
expect(commandArg.additionalModelRequestFields).toBeUndefined()
|
||||
})
|
||||
|
||||
|
|
@ -693,6 +694,7 @@ describe("AwsBedrockHandler", () => {
|
|||
const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any
|
||||
|
||||
// Should not include anthropic_beta for non-Sonnet 4 models
|
||||
expect(commandArg.anthropic_beta).toBeUndefined()
|
||||
expect(commandArg.additionalModelRequestFields).toBeUndefined()
|
||||
})
|
||||
|
||||
|
|
@ -740,11 +742,10 @@ describe("AwsBedrockHandler", () => {
|
|||
mockConverseStreamCommand.mock.calls.length - 1
|
||||
][0] as any
|
||||
|
||||
// Should include anthropic_beta in additionalModelRequestFields
|
||||
expect(commandArg.additionalModelRequestFields).toBeDefined()
|
||||
expect(commandArg.additionalModelRequestFields.anthropic_beta).toEqual(["context-1m-2025-08-07"])
|
||||
// Should include anthropic_beta at top level of payload
|
||||
expect(commandArg.anthropic_beta).toEqual(["context-1m-2025-08-07"])
|
||||
// Should not include anthropic_version since thinking is not enabled
|
||||
expect(commandArg.additionalModelRequestFields.anthropic_version).toBeUndefined()
|
||||
expect(commandArg.anthropic_version).toBeUndefined()
|
||||
// Model ID should have cross-region prefix
|
||||
expect(commandArg.modelId).toBe(`us.${BEDROCK_CLAUDE_SONNET_4_MODEL_ID}`)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -48,13 +48,12 @@ interface BedrockInferenceConfig {
|
|||
}
|
||||
|
||||
// Define interface for Bedrock additional model request fields
|
||||
// This includes thinking configuration, 1M context beta, and other model-specific parameters
|
||||
// This includes thinking configuration and other model-specific parameters
|
||||
interface BedrockAdditionalModelFields {
|
||||
thinking?: {
|
||||
type: "enabled"
|
||||
budget_tokens: number
|
||||
}
|
||||
anthropic_beta?: string[]
|
||||
[key: string]: any // Add index signature to be compatible with DocumentType
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +64,7 @@ interface BedrockPayload {
|
|||
system?: SystemContentBlock[]
|
||||
inferenceConfig: BedrockInferenceConfig
|
||||
anthropic_version?: string
|
||||
anthropic_beta?: string[]
|
||||
additionalModelRequestFields?: BedrockAdditionalModelFields
|
||||
}
|
||||
|
||||
|
|
@ -383,14 +383,6 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
const baseModelId = this.parseBaseModelId(modelConfig.id)
|
||||
const is1MContextEnabled = baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && this.options.awsBedrock1MContext
|
||||
|
||||
// Add anthropic_beta for 1M context to additionalModelRequestFields
|
||||
if (is1MContextEnabled) {
|
||||
if (!additionalModelRequestFields) {
|
||||
additionalModelRequestFields = {} as BedrockAdditionalModelFields
|
||||
}
|
||||
additionalModelRequestFields.anthropic_beta = ["context-1m-2025-08-07"]
|
||||
}
|
||||
|
||||
const payload: BedrockPayload = {
|
||||
modelId: modelConfig.id,
|
||||
messages: formatted.messages,
|
||||
|
|
@ -399,6 +391,8 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
...(additionalModelRequestFields && { additionalModelRequestFields }),
|
||||
// Add anthropic_version at top level when using thinking features
|
||||
...(thinkingEnabled && { anthropic_version: "bedrock-2023-05-31" }),
|
||||
// Add anthropic_beta at top level when 1M context is enabled
|
||||
...(is1MContextEnabled && { anthropic_beta: ["context-1m-2025-08-07"] }),
|
||||
}
|
||||
|
||||
// Create AbortController with 10 minute timeout
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue