[BUG] fix strip streaming empty-string suffix from DSV4 tool arguments (#29883)

This commit is contained in:
BingjiaWang
2026-07-10 02:05:26 -07:00
committed by GitHub
parent ecb7fb3989
commit fd19a76237
2 changed files with 81 additions and 3 deletions
@@ -2019,13 +2019,16 @@ class OpenAIServingChat(OpenAIServingBase):
# Get expected vs actual arguments
expected_args = detector.prev_tool_call_arr[tool_index].get("arguments", {})
expected_call = json.dumps(expected_args, ensure_ascii=False)
if isinstance(expected_args, str):
expected_call = expected_args
else:
expected_call = json.dumps(expected_args, ensure_ascii=False)
actual_call = detector.streamed_args_for_tool[tool_index]
# Check if there are remaining arguments to send
remaining_call = (
expected_call.replace(actual_call, "", 1)
if actual_call in expected_call
expected_call[len(actual_call) :]
if expected_call.startswith(actual_call)
else ""
)