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 <limitless@users.noreply.github.com>
This commit is contained in:
Limitless
2026-02-12 01:07:13 +08:00
committed by GitHub
parent 9d93bda3fe
commit 338d8a6610
@@ -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