[Bugfix] Bound Anthropic stop sequences (#51997)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
Taneem Ibrahim committed
Aug 12, 2026 at 18:05 UTC
6ea6c4265938df98e8797254c591be4d9fc04158
1 file changed
+6
-2
vllm/entrypoints/anthropic/protocol.py
+6
-2
@@ -3,10 +3,12 @@
3
"""Pydantic models for Anthropic API protocol"""
4
5
import time
6
-from typing import Any, Literal
6
+from typing import Annotated, Any, Literal
7
8
from pydantic import BaseModel, Field, field_validator, model_validator
9
10
+import vllm.envs as envs
11
+
12
13
class AnthropicError(BaseModel):
14
"""Error structure for Anthropic API"""
@@ -123,7 +125,9 @@ class AnthropicMessagesRequest(BaseModel):
125
max_tokens: int
126
metadata: dict[str, Any] | None = None
127
output_config: AnthropicOutputConfig | None = None
126
- stop_sequences: list[str] | None = None
128
+ stop_sequences: (
129
+ Annotated[list[str], Field(max_length=envs.VLLM_MAX_STOP_STRINGS)] | None
130
+ ) = None
131
stream: bool | None = False
132
system: str | list[AnthropicContentBlock] | None = None
133
temperature: float | None = None