From 0a5563d14af6cf4f1db292a5eaa92e97f4f87150 Mon Sep 17 00:00:00 2001 From: parisni Date: Thu, 14 May 2026 21:07:20 +0200 Subject: [PATCH] fix(bedrock): strip `client_metadata` from `filter_internal_params` Bedrock Converse with custom application inference profiles rejects any field in `additionalModelRequestFields` that the underlying inference profile does not whitelist. Some clients (OpenAI Codex CLI, Claude Code, others adopting OpenAI`s Responses API conventions) send a top-level `client_metadata` for run-level telemetry. LiteLLM forwards it via `additional_request_params`, and the Converse call fails with HTTP 400: The model returned the following errors: client_metadata: Extra inputs are not permitted `drop_params=true` does not cover this case because `client_metadata` is not a known OpenAI parameter, so it survives the OpenAI-side filtering and reaches the provider transformation untouched. Add `client_metadata` to the central `filter_internal_params` set so the sanitation happens once for every provider path that already calls this helper (Bedrock Converse, fallback router, etc.), instead of patching each provider individually. --- litellm/litellm_core_utils/core_helpers.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.py index e984df82140..b7d2e094756 100644 --- a/litellm/litellm_core_utils/core_helpers.py +++ b/litellm/litellm_core_utils/core_helpers.py @@ -426,11 +426,26 @@ def filter_internal_params( if not isinstance(data, dict): return data - # Known internal parameters that should never be sent to provider APIs + # Known internal parameters that should never be sent to provider APIs. + # + # ``client_metadata`` is sent by some clients (e.g. OpenAI Codex CLI, + # Claude Code) to attach run-level metadata. Most providers ignore + # unknown fields, but Bedrock Converse with custom *application + # inference profiles* rejects it because the underlying inference + # profile validates ``additionalModelRequestFields`` strictly: + # + # The model returned the following errors: client_metadata: Extra + # inputs are not permitted + # + # ``drop_params`` does not cover this because ``client_metadata`` is + # not a known OpenAI parameter, so it survives as part of + # ``additional_request_params`` and ends up in the Converse payload. + # Filter it here so every provider path sees the same sanitization. internal_params = { "skip_mcp_handler", "mcp_handler_context", "_skip_mcp_handler", + "client_metadata", } # Add any additional internal params if provided