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
+3 -1
View File
@@ -73,7 +73,9 @@ class TestHandleStop:
task = asyncio.create_task(slow_task())
await asyncio.sleep(0)
loop._active_tasks["test:c1"] = {task}
active_tasks = {task}
loop._active_tasks["test:c1"] = active_tasks
task.add_done_callback(active_tasks.discard)
msg = InboundMessage(channel="test", sender_id="u1", chat_id="c1", content="/stop")
ctx = CommandContext(msg=msg, session=None, key=msg.session_key, raw="/stop", loop=loop)