Преглед на файлове

fix(runner.py): 兼容调用工具时,不传任何参数的情况

tanjingyu преди 1 месец
родител
ревизия
c6f76152f5
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      agent/core/runner.py

+ 4 - 1
agent/core/runner.py

@@ -415,10 +415,13 @@ class AgentRunner:
                     for tc in tool_calls:
                         tool_name = tc["function"]["name"]
                         tool_args = tc["function"]["arguments"]
-                        if isinstance(tool_args, str):
+                        if tool_args and isinstance(tool_args, str):
                             import json
                             tool_args = json.loads(tool_args)
 
+                        if not tool_args:
+                            tool_args = {}
+
                         # 执行工具
                         tool_result = await self.tools.execute(
                             tool_name,