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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user