@@ -763,24 +763,26 @@ async def _parse_openai_completion(
763763 # 工具集未提供
764764 # Should be unreachable
765765 raise Exception ("工具集未提供" )
766- for tool in tools .func_list :
767- if (
768- tool_call .type == "function"
769- and tool .name == tool_call .function .name
770- ):
771- # workaround for #1454
772- if isinstance (tool_call .function .arguments , str ):
766+
767+ if tool_call .type == "function" :
768+ # workaround for #1454
769+ if isinstance (tool_call .function .arguments , str ):
770+ try :
773771 args = json .loads (tool_call .function .arguments )
774- else :
775- args = tool_call .function .arguments
776- args_ls .append (args )
777- func_name_ls .append (tool_call .function .name )
778- tool_call_ids .append (tool_call .id )
779-
780- # gemini-2.5 / gemini-3 series extra_content handling
781- extra_content = getattr (tool_call , "extra_content" , None )
782- if extra_content is not None :
783- tool_call_extra_content_dict [tool_call .id ] = extra_content
772+ except json .JSONDecodeError as e :
773+ logger .error (f"解析参数失败: { e } " )
774+ args = {}
775+ else :
776+ args = tool_call .function .arguments
777+ args_ls .append (args )
778+ func_name_ls .append (tool_call .function .name )
779+ tool_call_ids .append (tool_call .id )
780+
781+ # gemini-2.5 / gemini-3 series extra_content handling
782+ extra_content = getattr (tool_call , "extra_content" , None )
783+ if extra_content is not None :
784+ tool_call_extra_content_dict [tool_call .id ] = extra_content
785+
784786 llm_response .role = "tool"
785787 llm_response .tools_call_args = args_ls
786788 llm_response .tools_call_name = func_name_ls
0 commit comments