Skip to content

fix(bedrock): preserve reasoning_config on cross-provider translation - #5109

Merged
akshaydeo merged 1 commit into
maximhq:devfrom
Purvi09:fix/bedrock-reasoning-config-orderedmap
Jul 12, 2026
Merged

akshaydeo merged 1 commit into
maximhq:devfrom
Purvi09:fix/bedrock-reasoning-config-orderedmap

Conversation

@Purvi09

@Purvi09 Purvi09 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Bedrock Converse additionalModelRequestFields.reasoning_config / thinking
(and the Nova reasoningConfig variant) was silently dropped when a request
body was unmarshaled from JSON and then translated to a non-Bedrock
provider (e.g. an anthropic/... fallback). The outbound request had no
thinking enabled, so the model returned no reasoning — extended thinking was
lost on cross-provider fallbacks. Fixes #5108.

Changes

  • core/providers/bedrock/responses.goToBifrostResponsesRequest extracted
    reasoning_config/thinking and Nova reasoningConfig with a raw
    .(map[string]interface{}) type assertion. On the HTTP path, nested JSON
    objects decode to *OrderedMap (see decodeOrderedValue), so the assertion
    failed silently and Params.Reasoning was never populated. Both blocks
    now use schemas.SafeExtractOrderedMap(...).ToMap(), matching the sibling
    output_config block that already handles this shape.
  • core/providers/bedrock/bedrock_test.go — added
    TestReasoningConfigSurvivesHTTPUnmarshal, which unmarshals a real JSON body
    (not a Go map literal, which is why existing tests missed the bug) and
    asserts Params.Reasoning is populated. Covers both the Anthropic
    reasoning_config and Nova reasoningConfig paths.

Notes / trade-offs

  • Bedrock→Bedrock was never affected: the additionalModelRequestFieldPaths
    merge in utils.go re-injects the raw fields verbatim for Bedrock targets,
    which masked the bug for primaries.
  • No behavior change for in-process callers passing map[string]interface{}
    SafeExtractOrderedMap handles both shapes.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

go version

# Targeted regression test — fails on the pre-fix code, passes with the fix
go test ./core/providers/bedrock/ -run TestReasoningConfigSurvivesHTTPUnmarshal -v

# Full provider suite
go test ./core/providers/bedrock/

Expected: TestReasoningConfigSurvivesHTTPUnmarshal/reasoning_config and
/nova_reasoningConfig both PASS. Reverting the responses.go change makes
both fail with "reasoning_config was silently dropped".

No new configs or environment variables.

Screenshots/Recordings

N/A — no UI changes.

Breaking changes

  • Yes
  • No

Related issues

Closes #5108

Security considerations

None. No changes to auth, secrets, PII handling, or sandboxing.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed (N/A)
  • I verified builds succeed (Go and UI) — Go build/tests pass; no UI changes
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 562210e5-eace-47ad-aca3-69e86d1052b0

📥 Commits

Reviewing files that changed from the base of the PR and between 65f33df and 621c0b9.

📒 Files selected for processing (2)
  • core/providers/bedrock/bedrock_test.go
  • core/providers/bedrock/responses.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Preserved reasoning configuration when processing Bedrock requests received through HTTP.
    • Improved support for both standard and Nova reasoning settings, including token limits and effort levels.
  • Tests
    • Added coverage to verify reasoning settings remain available after request conversion.

Walkthrough

Changes

Bedrock reasoning configuration preservation

Layer / File(s) Summary
Ordered-map reasoning extraction
core/providers/bedrock/responses.go
Standard and Nova reasoning fields are extracted with schemas.SafeExtractOrderedMap and converted to plain maps before parameter parsing.
HTTP unmarshal regression coverage
core/providers/bedrock/bedrock_test.go
Tests verify that reasoning_config and reasoningConfig remain populated after JSON unmarshalling and request conversion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: akshaydeo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preserving Bedrock reasoning config during cross-provider translation.
Description check ✅ Passed The description covers the summary, changes, testing, impact, related issue, security, and checklist sections required by the template.
Linked Issues check ✅ Passed The code and new regression test address #5108 by preserving reasoning fields for HTTP-unmarshaled Bedrock requests to non-Bedrock providers.
Out of Scope Changes check ✅ Passed The PR stays focused on the Bedrock translation bug and its regression test, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from akshaydeo July 11, 2026 12:18
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The converter remains a pure request transformation.
  • The new tests cover the HTTP-unmarshal shape that this change fixes.

Important Files Changed

Filename Overview
core/providers/bedrock/responses.go Reasoning extraction now accepts OrderedMap-backed HTTP bodies and existing map-backed in-process inputs.
core/providers/bedrock/bedrock_test.go Adds focused tests proving reasoning settings survive JSON unmarshalling for Anthropic-style and Nova-style payloads.

Reviews (1): Last reviewed commit: "fix(bedrock): preserve reasoning_config ..." | Re-trigger Greptile

@akshaydeo
akshaydeo merged commit 3c77641 into maximhq:dev Jul 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants