[Test] Fix flaky test_function_call_required by adding strict=True (#22586)

This commit is contained in:
Liangsheng Yin
2026-04-11 02:14:22 -07:00
committed by GitHub
parent d14d368191
commit 7ab94e438c
@@ -464,6 +464,11 @@ class TestOpenAIServerFunctionCalling(CustomTestCase):
]
messages = [{"role": "user", "content": "What is the capital of France?"}]
# strict=True ensures constrained decoding enforces the parameter schema.
# Without it, tool_choice="required" only guarantees a tool call is made
# but arguments are best-effort (may be empty on small models).
for tool in tools:
tool["function"]["strict"] = True
response = client.chat.completions.create(
model=self.model,
max_tokens=2048,