fix double Unicode escape issue in streaming tool_calls parameters (#13518)

Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
This commit is contained in:
lw9527
2026-01-06 15:47:26 +08:00
committed by GitHub
parent 176266f358
commit 2724b1100b
2 changed files with 136 additions and 2 deletions

View File

@@ -249,7 +249,7 @@ class BaseFormatDetector(ABC):
if cur_arguments:
# Calculate how much of the arguments we've already streamed
sent = len(self.streamed_args_for_tool[self.current_tool_id])
cur_args_json = json.dumps(cur_arguments)
cur_args_json = json.dumps(cur_arguments, ensure_ascii=False)
prev_arguments = None
if self.current_tool_id < len(self.prev_tool_call_arr):
prev_arguments = self.prev_tool_call_arr[
@@ -270,7 +270,7 @@ class BaseFormatDetector(ABC):
# If the tool is still being parsed, send incremental changes
elif prev_arguments:
prev_args_json = json.dumps(prev_arguments)
prev_args_json = json.dumps(prev_arguments, ensure_ascii=False)
if cur_args_json != prev_args_json:
prefix = _find_common_prefix(prev_args_json, cur_args_json)
argument_diff = prefix[sent:]