Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion astrbot/core/agent/runners/tool_loop_agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,16 +738,18 @@ 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}")

if not func_tool:
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

Expand Down
36 changes: 19 additions & 17 deletions astrbot/core/provider/sources/openai_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down