From 625401a4d0232a23f97dfd0772c67db80c3351a2 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 17 Jan 2026 19:09:49 +0800 Subject: [PATCH] refactor: update event types for LLM tool usage and response --- astrbot/core/astr_agent_hooks.py | 4 ++-- astrbot/core/star/register/star_handler.py | 4 ++-- astrbot/core/star/star_handler.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/astrbot/core/astr_agent_hooks.py b/astrbot/core/astr_agent_hooks.py index 64523383f..fa0bb02a9 100644 --- a/astrbot/core/astr_agent_hooks.py +++ b/astrbot/core/astr_agent_hooks.py @@ -34,7 +34,7 @@ class MainAgentHooks(BaseAgentRunHooks[AstrAgentContext]): ): await call_event_hook( run_context.context.event, - EventType.OnCallingFuncToolEvent, + EventType.OnUsingLLMToolEvent, tool, tool_args, ) @@ -49,7 +49,7 @@ class MainAgentHooks(BaseAgentRunHooks[AstrAgentContext]): run_context.context.event.clear_result() await call_event_hook( run_context.context.event, - EventType.OnAfterCallingFuncToolEvent, + EventType.OnLLMToolRespondEvent, tool, tool_args, tool_result, diff --git a/astrbot/core/star/register/star_handler.py b/astrbot/core/star/register/star_handler.py index a2644feef..779144b40 100644 --- a/astrbot/core/star/register/star_handler.py +++ b/astrbot/core/star/register/star_handler.py @@ -427,7 +427,7 @@ def register_on_using_llm_tool(**kwargs): """ def decorator(awaitable): - _ = get_handler_or_create(awaitable, EventType.OnCallingFuncToolEvent, **kwargs) + _ = get_handler_or_create(awaitable, EventType.OnUsingLLMToolEvent, **kwargs) return awaitable return decorator @@ -453,7 +453,7 @@ def register_on_llm_tool_respond(**kwargs): def decorator(awaitable): _ = get_handler_or_create( - awaitable, EventType.OnAfterCallingFuncToolEvent, **kwargs + awaitable, EventType.OnLLMToolRespondEvent, **kwargs ) return awaitable diff --git a/astrbot/core/star/star_handler.py b/astrbot/core/star/star_handler.py index 7b2e9f4bf..6f5ce6090 100644 --- a/astrbot/core/star/star_handler.py +++ b/astrbot/core/star/star_handler.py @@ -189,7 +189,8 @@ class EventType(enum.Enum): OnLLMResponseEvent = enum.auto() # LLM 响应后 OnDecoratingResultEvent = enum.auto() # 发送消息前 OnCallingFuncToolEvent = enum.auto() # 调用函数工具 - OnAfterCallingFuncToolEvent = enum.auto() # 调用函数工具后 + OnUsingLLMToolEvent = enum.auto() # 使用 LLM 工具 + OnLLMToolRespondEvent = enum.auto() # 调用函数工具后 OnAfterMessageSentEvent = enum.auto() # 发送消息后