Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/api/providers/__tests__/bedrock-reasoning.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("AwsBedrockHandler - Extended Thinking", () => {
)
})

it("should include topP when thinking is disabled", async () => {
it("should not include topP when thinking is disabled (global removal)", async () => {
handler = new AwsBedrockHandler({
apiProvider: "bedrock",
apiModelId: "anthropic.claude-3-7-sonnet-20250219-v1:0",
Expand Down Expand Up @@ -216,10 +216,10 @@ describe("AwsBedrockHandler - Extended Thinking", () => {
chunks.push(chunk)
}

// Verify that topP IS present when thinking is disabled
// Verify that topP is NOT present for any model (removed globally)
expect(mockSend).toHaveBeenCalledTimes(1)
expect(capturedPayload).toBeDefined()
expect(capturedPayload.inferenceConfig).toHaveProperty("topP", 0.1)
expect(capturedPayload.inferenceConfig).not.toHaveProperty("topP")

// Verify that additionalModelRequestFields is not present or empty
expect(capturedPayload.additionalModelRequestFields).toBeUndefined()
Expand Down
10 changes: 2 additions & 8 deletions src/api/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from ".
interface BedrockInferenceConfig {
maxTokens: number
temperature?: number
topP?: number
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Contract change removes topP from BedrockInferenceConfig. Ensure related tests and any call sites that asserted/relied on topP are updated (e.g., src/api/providers/tests/bedrock-reasoning.spec.ts expectations when thinking is disabled).


// Define interface for Bedrock additional model request fields
Expand Down Expand Up @@ -374,12 +373,8 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
maxTokens: modelConfig.maxTokens || (modelConfig.info.maxTokens as number),
temperature: modelConfig.temperature ?? (this.options.modelTemperature as number),
}

if (!thinkingEnabled) {
inferenceConfig.topP = 0.1
}

// Check if 1M context is enabled for Claude Sonnet 4 / 4.5

// Check if 1M context is enabled for Claude Sonnet 4
// Use parseBaseModelId to handle cross-region inference prefixes
const baseModelId = this.parseBaseModelId(modelConfig.id)
const is1MContextEnabled =
Expand Down Expand Up @@ -649,7 +644,6 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
const inferenceConfig: BedrockInferenceConfig = {
maxTokens: modelConfig.maxTokens || (modelConfig.info.maxTokens as number),
temperature: modelConfig.temperature ?? (this.options.modelTemperature as number),
...(thinkingEnabled ? {} : { topP: 0.1 }), // Only set topP when thinking is NOT enabled
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Non-streaming path mirrors streaming config without topP. Consider adding/adjusting a unit test for completePrompt to assert that inferenceConfig does not include topP, to prevent regressions.


// For completePrompt, use a unique conversation ID based on the prompt
Expand Down
Loading