[Bugfix][Frontend] Reject Cohere REQUIRED tool choice without tools (#61825)

Signed-off-by: Kevin <jia__kuan@163.com>
This commit is contained in:
Jovan
2026-10-15 16:37:08 +00:00
committed by GitHub
parent d6f0b7a416
commit a9e90b9d1d
3 changed files with 47 additions and 1 deletions
+21
View File
@@ -95,6 +95,27 @@ class TestCohereChatV2Request:
tool_choice="ANY", # not REQUIRED/NONE
)
@pytest.mark.parametrize("tool_fields", [{}, {"tools": None}, {"tools": []}])
def test_required_tool_choice_requires_tools(self, tool_fields):
with pytest.raises(VLLMValidationError, match="REQUIRED.*tools") as exc_info:
CohereChatV2Request(
model="m",
messages=[{"role": "user", "content": "hi"}],
tool_choice="REQUIRED",
**tool_fields,
)
assert exc_info.value.parameter == "tool_choice"
@pytest.mark.parametrize("tool_choice", [None, "NONE"])
def test_nonrequired_tool_choice_allows_empty_tools(self, tool_choice):
request = CohereChatV2Request(
model="m",
messages=[{"role": "user", "content": "hi"}],
tool_choice=tool_choice,
tools=[],
)
assert request.tool_choice == tool_choice
def test_stop_sequences_bounded_by_env_limit(self):
messages = [{"role": "user", "content": "hi"}]
limit = envs.VLLM_MAX_STOP_STRINGS