From 6ea6c4265938df98e8797254c591be4d9fc04158 Mon Sep 17 00:00:00 2001 From: Taneem Ibrahim Date: Wed, 12 Aug 2026 18:05:12 +0200 Subject: [PATCH] [Bugfix] Bound Anthropic stop sequences (#51997) Signed-off-by: Taneem Ibrahim --- vllm/entrypoints/anthropic/protocol.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vllm/entrypoints/anthropic/protocol.py b/vllm/entrypoints/anthropic/protocol.py index 14c3e4aca7..80c354dacb 100644 --- a/vllm/entrypoints/anthropic/protocol.py +++ b/vllm/entrypoints/anthropic/protocol.py @@ -3,10 +3,12 @@ """Pydantic models for Anthropic API protocol""" import time -from typing import Any, Literal +from typing import Annotated, Any, Literal from pydantic import BaseModel, Field, field_validator, model_validator +import vllm.envs as envs + class AnthropicError(BaseModel): """Error structure for Anthropic API""" @@ -123,7 +125,9 @@ class AnthropicMessagesRequest(BaseModel): max_tokens: int metadata: dict[str, Any] | None = None output_config: AnthropicOutputConfig | None = None - stop_sequences: list[str] | None = None + stop_sequences: ( + Annotated[list[str], Field(max_length=envs.VLLM_MAX_STOP_STRINGS)] | None + ) = None stream: bool | None = False system: str | list[AnthropicContentBlock] | None = None temperature: float | None = None