A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 8, 06:15 UTC
[CI][Frontend] Return 422 instead of 500 for invalid Anthropic tool_choice (#34590)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Andreas Karatzas committed
Feb 15, 2026 at 22:06 UTC
974d829b0532a27d55ac625271a4149225dec5ba
2 files changed
+8
-1
tests/entrypoints/openai/test_openai_schema.py
+1
@@ -151,6 +151,7 @@ def test_openapi_stateless(case: schemathesis.Case):
151
# requires a longer timeout
152
("POST", "/v1/chat/completions"): LONG_TIMEOUT_SECONDS,
153
("POST", "/v1/completions"): LONG_TIMEOUT_SECONDS,
154
+ ("POST", "/v1/messages"): LONG_TIMEOUT_SECONDS,
155
}.get(key, DEFAULT_TIMEOUT_SECONDS)
156
157
# No need to verify SSL certificate for localhost
vllm/entrypoints/anthropic/protocol.py
+7
-1
@@ -5,7 +5,7 @@
5
import time
6
from typing import Any, Literal
7
8
-from pydantic import BaseModel, field_validator
8
+from pydantic import BaseModel, field_validator, model_validator
9
10
11
class AnthropicError(BaseModel):
@@ -76,6 +76,12 @@ class AnthropicToolChoice(BaseModel):
76
type: Literal["auto", "any", "tool"]
77
name: str | None = None
78
79
+ @model_validator(mode="after")
80
+ def validate_name_required_for_tool(self) -> "AnthropicToolChoice":
81
+ if self.type == "tool" and not self.name:
82
+ raise ValueError("tool_choice.name is required when type is 'tool'")
83
+ return self
84
+
85
86
class AnthropicMessagesRequest(BaseModel):
87
"""Anthropic Messages API request"""