Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ const bedrockSchema = apiModelIdProviderModelSchema.extend({
awsApiKey: z.string().optional(),
awsUseApiKey: z.boolean().optional(),
awsCustomArn: z.string().optional(),
awsCustomArnEnableReasoning: z.boolean().optional(), // Enable reasoning for custom ARNs
awsModelContextWindow: z.number().optional(),
awsBedrockEndpointEnabled: z.boolean().optional(),
awsBedrockEndpoint: z.string().optional(),
Expand Down
15 changes: 13 additions & 2 deletions src/api/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,13 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
modelConfig.reasoning &&
modelConfig.reasoningBudget

if ((isThinkingExplicitlyEnabled || isThinkingEnabledBySettings) && modelConfig.info.supportsReasoningBudget) {
// For custom ARNs, only enable reasoning if explicitly enabled via the awsCustomArnEnableReasoning setting
// For regular models, use the standard logic
const shouldEnableThinking = this.options.awsCustomArn
? this.options.awsCustomArnEnableReasoning && modelConfig.info.supportsReasoningBudget
: (isThinkingExplicitlyEnabled || isThinkingEnabledBySettings) && modelConfig.info.supportsReasoningBudget

if (shouldEnableThinking) {
thinkingEnabled = true
additionalModelRequestFields = {
thinking: {
Expand Down Expand Up @@ -717,11 +723,16 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH

// For completePrompt, thinking is typically not used, but we should still check
// if thinking was somehow enabled in the model config
const thinkingEnabled =
// For custom ARNs, only enable if explicitly set via awsCustomArnEnableReasoning
const thinkingEnabledBySettings =
shouldUseReasoningBudget({ model: modelConfig.info, settings: this.options }) &&
modelConfig.reasoning &&
modelConfig.reasoningBudget

const thinkingEnabled = this.options.awsCustomArn
? this.options.awsCustomArnEnableReasoning && modelConfig.reasoning && modelConfig.reasoningBudget
: thinkingEnabledBySettings
Comment on lines +732 to +734
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The condition here uses modelConfig.reasoning && modelConfig.reasoningBudget, but in createMessage() the equivalent check uses modelConfig.info.supportsReasoningBudget. This inconsistency could cause reasoning to be enabled in streaming calls but not in non-streaming calls (or vice versa) for the same custom ARN and settings. Consider aligning both methods to use the same condition:

Suggested change
const thinkingEnabled = this.options.awsCustomArn
? this.options.awsCustomArnEnableReasoning && modelConfig.reasoning && modelConfig.reasoningBudget
: thinkingEnabledBySettings
const thinkingEnabled = this.options.awsCustomArn
? this.options.awsCustomArnEnableReasoning && modelConfig.info.supportsReasoningBudget && modelConfig.reasoning && modelConfig.reasoningBudget
: thinkingEnabledBySettings

Fix it with Roo Code or mention @roomote and request a fix.


const inferenceConfig: BedrockInferenceConfig = {
maxTokens: modelConfig.maxTokens || (modelConfig.info.maxTokens as number),
temperature: modelConfig.temperature ?? (this.options.modelTemperature as number),
Expand Down
14 changes: 14 additions & 0 deletions webview-ui/src/components/settings/providers/Bedrock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
</div>
</>
)}
{apiConfiguration?.awsCustomArn && (
<div>
<Checkbox
checked={apiConfiguration?.awsCustomArnEnableReasoning ?? false}
onChange={(checked: boolean) => {
setApiConfigurationField("awsCustomArnEnableReasoning", checked)
}}>
Enable Reasoning
</Checkbox>
<div className="text-sm text-vscode-descriptionForeground mt-1 ml-6">
Enable extended thinking for this custom ARN. Only enable if the model supports reasoning.
</div>
</div>
)}
</>
)
}
Loading