Fix parallel tool call test for speculative decoding variants (#19370)

Co-authored-by: Alison Shao <alisonshao@Mac.attlocal.net>
Co-authored-by: Alison Shao <alisonshao@MacBook-Pro-D2W773R9CD.local>
This commit is contained in:
Alison Shao
2026-02-26 18:31:20 -08:00
committed by GitHub
co-authored by Alison Shao Alison Shao
parent 5b5c509480
commit c2dce06d9f
+21 -6
View File
@@ -77,15 +77,28 @@ ADD_TOOL_STRICT = {
"function": {**ADD_TOOL["function"], "strict": True}, "function": {**ADD_TOOL["function"], "strict": True},
} }
WEATHER_TOOL_STRICT = {
"type": "function",
"function": {**WEATHER_TOOL["function"], "strict": True},
}
def _call(client, model, content, tools=None, tool_choice="required", **kwargs):
def _call(
client,
model,
content,
tools=None,
tool_choice="required",
temperature=0.1,
**kwargs,
):
"""Single-turn tool call request. Defaults to ADD_TOOL_STRICT + required.""" """Single-turn tool call request. Defaults to ADD_TOOL_STRICT + required."""
return client.chat.completions.create( return client.chat.completions.create(
model=model, model=model,
messages=[{"role": "user", "content": content}], messages=[{"role": "user", "content": content}],
tools=tools or [ADD_TOOL_STRICT], tools=tools or [ADD_TOOL_STRICT],
tool_choice=tool_choice, tool_choice=tool_choice,
temperature=0.1, temperature=temperature,
**kwargs, **kwargs,
) )
@@ -265,8 +278,10 @@ def _test_parallel(client, model):
response = _call( response = _call(
client, client,
model, model,
"What is 3+5 and what is the weather in Tokyo?", "Please call both functions: use add to compute 3+5, and use get_weather to check the weather in Tokyo.",
tools=[ADD_TOOL, WEATHER_TOOL], tools=[ADD_TOOL_STRICT, WEATHER_TOOL_STRICT],
tool_choice="auto",
temperature=0,
) )
tc = response.choices[0].message.tool_calls tc = response.choices[0].message.tool_calls
assert tc and len(tc) >= 2, f"expected >= 2 tool calls, got {len(tc) if tc else 0}" assert tc and len(tc) >= 2, f"expected >= 2 tool calls, got {len(tc) if tc else 0}"
@@ -329,11 +344,11 @@ def run_tool_call_test(
"""Launch server, run enabled test cases, return results.""" """Launch server, run enabled test cases, return results."""
base_url = base_url or DEFAULT_URL_FOR_TEST base_url = base_url or DEFAULT_URL_FOR_TEST
print(f"\n{'='*60}") print(f"\n{'=' * 60}")
print(f"Running TOOL CALL test for {model.model_path}") print(f"Running TOOL CALL test for {model.model_path}")
if model.variant: if model.variant:
print(f" Variant: {model.variant}") print(f" Variant: {model.variant}")
print(f"{'='*60}\n") print(f"{'=' * 60}\n")
process = None process = None
try: try: