This commit is contained in:
Filippo Menghi 2026-08-27 16:35:25 -05:00 committed by GitHub
commit 5675b0f6cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View file

@ -1962,8 +1962,13 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
optional_params.pop("metadata")
# Remove internal LiteLLM parameters that should not be sent to Anthropic API
optional_params.pop("is_vertex_request", None)
optional_params.pop("client_metadata", None)
for internal_param in (
"is_vertex_request",
"client_metadata",
"vector_store_ids",
"vector_store_id",
):
optional_params.pop(internal_param, None)
# ``top_k`` is a provider-specific kwarg that bypasses
# ``map_openai_params``; gate it here, the single boundary shared by

View file

@ -5996,6 +5996,25 @@ def test_client_metadata_stripped_from_anthropic_request():
assert "client_metadata" not in result
def test_transform_request_strips_vector_store_ids():
"""vector_store_ids injected by proxy vector store hooks must not reach the Anthropic payload."""
config = AnthropicConfig()
result = config.transform_request(
model="claude-3-5-haiku-20241022",
messages=[{"role": "user", "content": "hello"}],
optional_params={
"max_tokens": 10,
"vector_store_ids": ["vs_abc123"],
"vector_store_id": "vs_abc123",
},
litellm_params={},
headers={},
)
assert "vector_store_ids" not in result
assert "vector_store_id" not in result
assert result["max_tokens"] == 10
@pytest.mark.parametrize(
"model",
["claude-fable-5", "claude-opus-4-7", "claude-opus-4-8-20260120"],