Skip to content

fix(bedrock): strip client_metadata from converse additionalModelRequestFields - #35967

Open
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_bedrock_strip_client_metadata
Open

fix(bedrock): strip client_metadata from converse additionalModelRequestFields#35967
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_bedrock_strip_client_metadata

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Drop client_metadata from additionalModelRequestFields in Converse
  • Regression test asserts real passthrough fields still survive

Relevant issues

Linear ticket

Resolves LIT-5232

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Codex is the only client that sends client_metadata, so the failure only shows up on Codex -> proxy -> Bedrock. Converse forwards anything it doesn't recognize as additionalModelRequestFields, Bedrock hands that to the model verbatim, and Anthropic answers with client_metadata: Extra inputs are not permitted

Proxy config used for both runs:

model_list:
  - model_name: claude-opus-4-8
    litellm_params:
      model: bedrock/us.anthropic.claude-opus-4-8
      aws_region_name: us-west-2
litellm_settings:
  drop_params: true

Same curl for both runs, the exact body Codex sends:

curl -s -X POST http://localhost:4000/v1/responses \
  -H 'Content-Type: application/json' -H 'Authorization: Bearer sk-1234' \
  -d '{"model":"claude-opus-4-8","input":"say hi","max_output_tokens":16,"client_metadata":{"originator":"codex_cli_rs"}}'

Before, at 0659738, the request the proxy builds for Bedrock (from --detailed_debug, drop_params: true active and not helping):

-d '{"messages": [{"role": "user", "content": [{"text": "say hi"}]}], "inferenceConfig": {"maxTokens": 16}, "additionalModelRequestFields": {"client_metadata": {"originator": "codex_cli_rs"}}}'

After, at cdac5fd, same curl, no passthrough field left for Bedrock to reject:

-d '{"messages": [{"role": "user", "content": [{"text": "say hi"}]}], "inferenceConfig": {"maxTokens": 16}}'

Both runs stopped at Bedrock auth: the AWS credentials I have access to are no longer authorized for bedrock:InvokeModel on this account, so I could not get a paid 200 back. The before/after difference is in the request LiteLLM signs and sends, which is exactly the field Bedrock was rejecting, so someone with working Bedrock credentials can confirm the 200 in a minute

Until a release ships, additional_drop_params: ["client_metadata"] on the model works as a config-only workaround, and it stays a valid escape hatch afterwards

Type

🐛 Bug Fix

Changes

AmazonConverseConfig._prepare_request_params drops client_metadata next to where it already drops parallel_tool_calls, so it never reaches additionalModelRequestFields. AnthropicConfig.transform_request does the same thing for the direct Anthropic, Vertex, and Bedrock invoke paths, this closes the one remaining hole

Note that drop_params is the wrong lever here and always was: it only governs known OpenAI params a provider does not support, while client_metadata is not an OpenAI param, so it flows through the provider-specific passthrough instead

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/e57cd0ce775749e595f7da41d0795378

…estFields

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents Codex’s unsupported client_metadata field from being forwarded through Bedrock Converse while preserving legitimate model-specific passthrough fields.

  • Removes client_metadata before constructing additionalModelRequestFields.
  • Adds regression coverage confirming removal while retaining anthropic_beta.

Confidence Score: 5/5

The PR appears safe to merge, with the unsupported metadata removed from every Bedrock Converse request-construction path.

The exact field is removed before additional model request fields are serialized, both synchronous and asynchronous paths use that transformation, and the regression test confirms legitimate passthrough data remains intact.

Important Files Changed

Filename Overview
litellm/llms/bedrock/chat/converse_transformation.py Safely removes the unsupported field from the common synchronous and asynchronous Converse request-building path.
tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py Adds focused regression coverage that verifies the offending field is removed without dropping a valid passthrough field.

Reviews (1): Last reviewed commit: "fix(bedrock): strip client_metadata from..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_bedrock_strip_client_metadata (cdac5fd) with litellm_internal_staging (54fb717)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (0659738) during the generation of this report, so 54fb717 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@pjahanlou-godaddy

Copy link
Copy Markdown

Do we have plans on reviewing and getting this into main?

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.

2 participants