Merge pull request #35967 from BerriAI/litellm_bedrock_strip_client_metadata

fix(bedrock): strip client_metadata from converse additionalModelRequestFields
This commit is contained in:
Mateo Wang 2026-09-02 16:46:48 -07:00 committed by GitHub
commit ff71808671
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View file

@ -1337,6 +1337,7 @@ class AmazonConverseConfig(BaseConfig):
)
additional_request_params.pop("parallel_tool_calls", None)
additional_request_params.pop("client_metadata", None)
# Only set the topK value in for models that support it
additional_request_params.update(self._handle_top_k_value(model, inference_params, drop_params))

View file

@ -979,6 +979,34 @@ def test_config_blocks_do_not_leak_into_inference_config():
assert data["serviceTier"] == {"type": "priority"}
@pytest.mark.parametrize(
"model",
[
"anthropic.claude-opus-4-8",
"us.anthropic.claude-opus-4-8",
"amazon.nova-pro-v1:0",
"us.meta.llama4-maverick-17b-instruct-v1:0",
"arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abcdef123456",
"arn:aws:bedrock:us-east-1:123456789012:inference-profile/us.amazon.nova-pro-v1:0",
],
)
def test_client_metadata_stripped_from_converse_request(model):
data = AmazonConverseConfig()._transform_request_helper(
model=model,
system_content_blocks=[],
optional_params={
"maxTokens": 16,
"anthropic_beta": ["computer-use-2025-01-24"],
"client_metadata": {"originator": "codex_cli_rs"},
},
messages=None,
)
fields = data["additionalModelRequestFields"]
assert "client_metadata" not in fields
assert fields["anthropic_beta"] == ["computer-use-2025-01-24"]
def test_parallel_tool_calls_config_kept_for_sonnet_5(monkeypatch):
old_env = os.environ.get("LITELLM_LOCAL_MODEL_COST_MAP")
old_cost = litellm.model_cost