Skip to content

Commit 3a9429e

Browse files
committed
fix: on_tool_end hook unavailable
1 parent c4eb1ab commit 3a9429e

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

astrbot/core/agent/runners/tool_loop_agent_runner.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,6 @@ async def _handle_function_tools(
269269
)
270270
yield MessageChain().message("返回的数据类型不受支持。")
271271

272-
try:
273-
await self.agent_hooks.on_tool_end(
274-
self.run_context,
275-
func_tool_name,
276-
func_tool_args,
277-
resp,
278-
)
279-
except Exception as e:
280-
logger.error(
281-
f"Error in on_tool_end hook: {e}", exc_info=True
282-
)
283272
elif resp is None:
284273
# Tool 直接请求发送消息给用户
285274
# 这里我们将直接结束 Agent Loop。
@@ -289,27 +278,17 @@ async def _handle_function_tools(
289278
yield MessageChain(
290279
chain=res.chain, type="tool_direct_result"
291280
)
292-
try:
293-
await self.agent_hooks.on_tool_end(
294-
self.run_context, func_tool_name, func_tool_args, None
295-
)
296-
except Exception as e:
297-
logger.error(
298-
f"Error in on_tool_end hook: {e}", exc_info=True
299-
)
300281
else:
301282
logger.warning(
302283
f"Tool 返回了不支持的类型: {type(resp)},将忽略。"
303284
)
304285

305-
try:
306-
await self.agent_hooks.on_tool_end(
307-
self.run_context, func_tool_name, func_tool_args, None
308-
)
309-
except Exception as e:
310-
logger.error(
311-
f"Error in on_tool_end hook: {e}", exc_info=True
312-
)
286+
try:
287+
await self.agent_hooks.on_tool_end(
288+
self.run_context, func_tool, func_tool_args, None
289+
)
290+
except Exception as e:
291+
logger.error(f"Error in on_tool_end hook: {e}", exc_info=True)
313292

314293
self.run_context.event.clear_result()
315294
except Exception as e:

0 commit comments

Comments
 (0)