Skip to content

fix(ai-proxy): map adaptive effort to sibling output_config in Bedrock - #4205

Open
srpatcha wants to merge 1 commit into
higress-group:mainfrom
srpatcha:fix/bedrock-adaptive-effort-nesting
Open

fix(ai-proxy): map adaptive effort to sibling output_config in Bedrock#4205
srpatcha wants to merge 1 commit into
higress-group:mainfrom
srpatcha:fix/bedrock-adaptive-effort-nesting

Conversation

@srpatcha

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR does

Fixes #4170

When ai-proxy converts a Claude request with adaptive thinking and an output effort level to an Amazon Bedrock Converse request, it placed effort inside the thinking object. Bedrock expects thinking and output_config to be sibling fields in additionalModelRequestFields.

Ⅱ. Behavior

For a request containing:

{ "thinking": { "type": "adaptive" }, "output_config": { "effort": "high" } }

Before:

{ "thinking": { "type": "adaptive", "effort": "high" } }

(output_config lost, effort at wrong nesting level)

After:

{ "thinking": { "type": "adaptive" }, "output_config": { "effort": "high" } }

Ⅲ. Changes

  • provider/bedrock.go — set output_config.effort as a sibling of thinking in additionalModelRequestFields instead of nesting effort inside thinking.
  • provider/bedrock_thinking_test.go — updated the adaptive-effort test to assert the sibling structure (renamed ...IntoThinking...ToSiblingOutputConfig).

Ⅳ. Scope

Supported effort values remain low/medium/high; unsupported values are still omitted. Manual extended thinking (budget_tokens) and requests without adaptive thinking are unaffected — covered by the existing TestBedrockRequestDropsOutputEffortWithoutAdaptiveThinking and TestBedrockRequestDropsUnsupportedAdaptiveOutputEffort tests which continue to pass.

When converting a Claude request with adaptive thinking and an output
effort level to an Amazon Bedrock Converse request, ai-proxy placed
`effort` inside the `thinking` object. Bedrock expects `thinking` and
`output_config` to be sibling fields in additionalModelRequestFields.

Before, a request with:
  { "thinking": { "type": "adaptive" }, "output_config": { "effort": "high" } }
produced:
  { "thinking": { "type": "adaptive", "effort": "high" } }

losing the output_config structure and sending effort at the wrong
nesting level.

Now the two categories are preserved as siblings:
  { "thinking": { "type": "adaptive" }, "output_config": { "effort": "high" } }

Supported effort values remain low/medium/high; unsupported values are
still omitted. Manual extended thinking (budget_tokens) and requests
without adaptive thinking are unaffected.

Updated TestBedrockRequestMapsAdaptiveOutputEffortIntoThinking
accordingly (renamed to ...ToSiblingOutputConfig).

Fixes higress-group#4170

Signed-off-by: Srikanth Patchava <spatchava@meta.com>
@codecov-commenter

codecov-commenter commented Jul 24, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@afb72b8). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4205   +/-   ##
=======================================
  Coverage        ?   69.25%           
=======================================
  Files           ?      170           
  Lines           ?    33773           
  Branches        ?        0           
=======================================
  Hits            ?    23390           
  Misses          ?     9539           
  Partials        ?      844           
Flag Coverage Δ
wasm-go-plugin-ai-proxy 81.39% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ns/wasm-go/extensions/ai-proxy/provider/bedrock.go 68.76% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude adaptive effort is nested incorrectly in Bedrock Converse requests

2 participants