Fix a robust parsing issue in KimiK2ToolParser that causes IndexError (#27565)

Signed-off-by: wangln19 <wanglinian@dev.wanglinian.msh-dev.svc.cluster.local>
Co-authored-by: wangln19 <wanglinian@dev.wanglinian.msh-dev.svc.cluster.local>
This commit is contained in:
wangln19
2025-10-28 19:11:50 +08:00
committed by GitHub
parent 0291fbf65c
commit 2fa90bda27
2 changed files with 7 additions and 7 deletions

View File

@ -37,11 +37,11 @@ def assert_tool_calls(
assert actual_tool_call.type == "function"
assert actual_tool_call.function == expected_tool_call.function
# assert tool call id format
assert actual_tool_call.id.startswith("functions.")
# assert tool call id format: should contain function name and numeric index
# Format can be either "functions.func_name:0" or "func_name:0"
assert actual_tool_call.id.split(":")[-1].isdigit()
assert (
actual_tool_call.id.split(".")[1].split(":")[0]
actual_tool_call.id.split(":")[0].split(".")[-1]
== expected_tool_call.function.name
)