diff --git a/astrbot/core/agent/runners/tool_loop_agent_runner.py b/astrbot/core/agent/runners/tool_loop_agent_runner.py index 3fb487cbe6..f6de9a1da2 100644 --- a/astrbot/core/agent/runners/tool_loop_agent_runner.py +++ b/astrbot/core/agent/runners/tool_loop_agent_runner.py @@ -738,8 +738,10 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None: # in 'skills_like' mode, raw.func_tool is light schema, does not have handler # so we need to get the tool from the raw tool set func_tool = self._skill_like_raw_tool_set.get_tool(func_tool_name) + available_tools = self._skill_like_raw_tool_set.names() else: func_tool = req.func_tool.get_tool(func_tool_name) + available_tools = req.func_tool.names() logger.info(f"使用工具:{func_tool_name},参数:{func_tool_args}") @@ -747,7 +749,7 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None: logger.warning(f"未找到指定的工具: {func_tool_name},将跳过。") _append_tool_call_result( func_tool_id, - f"error: Tool {func_tool_name} not found.", + f"error: Tool {func_tool_name} not found. Available tools are: {', '.join(available_tools)}", ) continue diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 33432b6636..682c75b76f 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -763,24 +763,26 @@ async def _parse_openai_completion( # 工具集未提供 # Should be unreachable raise Exception("工具集未提供") - for tool in tools.func_list: - if ( - tool_call.type == "function" - and tool.name == tool_call.function.name - ): - # workaround for #1454 - if isinstance(tool_call.function.arguments, str): + + if tool_call.type == "function": + # workaround for #1454 + if isinstance(tool_call.function.arguments, str): + try: args = json.loads(tool_call.function.arguments) - else: - args = tool_call.function.arguments - args_ls.append(args) - func_name_ls.append(tool_call.function.name) - tool_call_ids.append(tool_call.id) - - # gemini-2.5 / gemini-3 series extra_content handling - extra_content = getattr(tool_call, "extra_content", None) - if extra_content is not None: - tool_call_extra_content_dict[tool_call.id] = extra_content + except json.JSONDecodeError as e: + logger.error(f"解析参数失败: {e}") + args = {} + else: + args = tool_call.function.arguments + args_ls.append(args) + func_name_ls.append(tool_call.function.name) + tool_call_ids.append(tool_call.id) + + # gemini-2.5 / gemini-3 series extra_content handling + extra_content = getattr(tool_call, "extra_content", None) + if extra_content is not None: + tool_call_extra_content_dict[tool_call.id] = extra_content + llm_response.role = "tool" llm_response.tools_call_args = args_ls llm_response.tools_call_name = func_name_ls