From 338d8a66100f2386491e13f7a429caa4381795fd Mon Sep 17 00:00:00 2001 From: Limitless <127183162+Limitless2023@users.noreply.github.com> Date: Thu, 12 Feb 2026 01:07:13 +0800 Subject: [PATCH] fix: close unawaited reset coroutine on early return (#5033) When an OnLLMRequestEvent hook stops event propagation, the reset_coro created by build_main_agent was never awaited, causing a RuntimeWarning. Close the coroutine explicitly before returning. Fixes #5032 Co-authored-by: Limitless2023 --- .../pipeline/process_stage/method/agent_sub_stages/internal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py index d26f67add..0abee033d 100644 --- a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py +++ b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py @@ -190,6 +190,8 @@ class InternalAgentSubStage(Stage): ) if await call_event_hook(event, EventType.OnLLMRequestEvent, req): + if reset_coro: + reset_coro.close() return # apply reset