[Bugfix][Frontend] Apply the stop string limit to Cohere requests (#53750)

Signed-off-by: mhuzaifa3 <mhuzaifa3@outlook.com>
This commit is contained in:
Moe Huzaifa
2026-08-25 16:41:08 +00:00
committed by GitHub
parent 3e833933dc
commit 217a0b5cef
2 changed files with 24 additions and 2 deletions
+19
View File
@@ -16,6 +16,7 @@ types plus a few local additions:
import pytest
from pydantic import ValidationError
import vllm.envs as envs
from vllm.entrypoints.cohere.protocol import (
AssistantMessageResponse,
CitationEndEvent,
@@ -94,6 +95,24 @@ class TestCohereChatV2Request:
tool_choice="ANY", # not REQUIRED/NONE
)
def test_stop_sequences_bounded_by_env_limit(self):
messages = [{"role": "user", "content": "hi"}]
limit = envs.VLLM_MAX_STOP_STRINGS
req = CohereChatV2Request(
model="m",
messages=messages,
stop_sequences=[f"s{i}" for i in range(limit)],
)
assert len(req.stop_sequences) == limit
with pytest.raises(ValidationError):
CohereChatV2Request(
model="m",
messages=messages,
stop_sequences=[f"s{i}" for i in range(limit + 1)],
)
# ======================================================================
# Usage / Logprobs