From e2f83aadcf1298cb255b48dd76cf8d9a9680abc5 Mon Sep 17 00:00:00 2001 From: sclfcz Date: Fri, 25 Sep 2026 23:45:49 +0800 Subject: [PATCH] test(llm_response_utils): expand one parallel call into two tool uses Addresses review feedback: with one tool use per parallel call the replacement never changed the list length, so the test did not pin the offset arithmetic. Now the first splice changes the length and the second has to land at the shifted offset. --- .../test_convert_dict_to_chat_completion.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py b/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py index 1a5fbe95b5a..ff0bd628ab3 100644 --- a/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py +++ b/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py @@ -2497,7 +2497,7 @@ def test_convert_to_model_response_object_expands_every_parallel_tool_call(): one stayed in place and the call after it was overwritten. """ - def parallel(call_id, recipient_name, parameters): + def parallel(call_id, *calls): return { "id": call_id, "type": "function", @@ -2506,10 +2506,8 @@ def test_convert_to_model_response_object_expands_every_parallel_tool_call(): "arguments": json.dumps( { "tool_uses": [ - { - "recipient_name": recipient_name, - "parameters": parameters, - } + {"recipient_name": name, "parameters": params} + for name, params in calls ] } ), @@ -2537,9 +2535,16 @@ def test_convert_to_model_response_object_expands_every_parallel_tool_call(): "content": None, "tool_calls": [ plain("0", "get_weather"), - parallel("m1", "functions.get_time", {"tz": "UTC"}), + # Two expansions here and one below, so the first splice + # changes the list length and the second splice has to land + # at the shifted offset. + parallel( + "m1", + ("functions.get_time", {"tz": "UTC"}), + ("functions.get_date", {"tz": "UTC"}), + ), plain("2", "get_news"), - parallel("m2", "functions.get_quote", {"sym": "AAPL"}), + parallel("m2", ("functions.get_quote", {"sym": "AAPL"})), plain("4", "get_forecast"), ], }, @@ -2557,6 +2562,7 @@ def test_convert_to_model_response_object_expands_every_parallel_tool_call(): assert names == [ "get_weather", "get_time", + "get_date", "get_news", "get_quote", "get_forecast",