mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix(bedrock): scope client_metadata drop to anthropic converse models
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
ab11613441
commit
ed4343a026
2 changed files with 28 additions and 4 deletions
|
|
@ -1324,7 +1324,13 @@ class AmazonConverseConfig(BaseConfig):
|
|||
)
|
||||
|
||||
additional_request_params.pop("parallel_tool_calls", None)
|
||||
additional_request_params.pop("client_metadata", None)
|
||||
|
||||
if base_model.startswith("anthropic") and additional_request_params.pop("client_metadata", None) is not None:
|
||||
litellm.verbose_logger.debug(
|
||||
"Bedrock Converse: dropping `client_metadata` for model=%s, Anthropic rejects it with "
|
||||
"'client_metadata: Extra inputs are not permitted'",
|
||||
model,
|
||||
)
|
||||
|
||||
# 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))
|
||||
|
|
|
|||
|
|
@ -979,8 +979,9 @@ def test_config_blocks_do_not_leak_into_inference_config():
|
|||
assert data["serviceTier"] == {"type": "priority"}
|
||||
|
||||
|
||||
def test_client_metadata_stripped_from_converse_request():
|
||||
"""``client_metadata`` sent by codex must not reach Bedrock as a passthrough model field.
|
||||
@pytest.mark.parametrize("model", ["anthropic.claude-opus-4-8", "us.anthropic.claude-opus-4-8"])
|
||||
def test_client_metadata_stripped_for_anthropic_converse_request(model):
|
||||
"""``client_metadata`` sent by codex must not reach Anthropic as a passthrough model field.
|
||||
|
||||
Converse forwards ``additionalModelRequestFields`` verbatim to the model, and Anthropic
|
||||
rejects the request with "client_metadata: Extra inputs are not permitted".
|
||||
|
|
@ -988,7 +989,7 @@ def test_client_metadata_stripped_from_converse_request():
|
|||
config = AmazonConverseConfig()
|
||||
|
||||
data = config._transform_request_helper(
|
||||
model="anthropic.claude-opus-4-8",
|
||||
model=model,
|
||||
system_content_blocks=[],
|
||||
optional_params={
|
||||
"maxTokens": 16,
|
||||
|
|
@ -1003,6 +1004,23 @@ def test_client_metadata_stripped_from_converse_request():
|
|||
assert fields["anthropic_beta"] == ["computer-use-2025-01-24"]
|
||||
|
||||
|
||||
def test_client_metadata_kept_for_non_anthropic_converse_request():
|
||||
"""Only Anthropic is known to reject ``client_metadata``, so other families keep the passthrough."""
|
||||
config = AmazonConverseConfig()
|
||||
|
||||
data = config._transform_request_helper(
|
||||
model="amazon.nova-pro-v1:0",
|
||||
system_content_blocks=[],
|
||||
optional_params={
|
||||
"maxTokens": 16,
|
||||
"client_metadata": {"originator": "codex_cli_rs"},
|
||||
},
|
||||
messages=None,
|
||||
)
|
||||
|
||||
assert data["additionalModelRequestFields"]["client_metadata"] == {"originator": "codex_cli_rs"}
|
||||
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue