fix(agent): snapshot active tasks before cancellation

This commit is contained in:
chengyongru
2026-07-28 15:42:52 +08:00
committed by chengyongru
parent ce3e532643
commit 78cf68c291
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -760,7 +760,7 @@ class AgentLoop:
Returns the total number of cancelled tasks + subagents.
"""
tasks = self._active_tasks.pop(key, set())
tasks = tuple(self._active_tasks.pop(key, set()))
cancelled = sum(1 for t in tasks if not t.done() and t.cancel())
for t in tasks:
with suppress(asyncio.CancelledError, Exception):