fix(agent): stop session-owned exec processes
This commit is contained in:
@@ -788,9 +788,9 @@ class AgentLoop:
|
||||
logger.warning("Command '{}' matched but dispatch returned None", raw)
|
||||
|
||||
async def _cancel_active_tasks(self, key: str) -> int:
|
||||
"""Cancel and await all active tasks and subagents for *key*.
|
||||
"""Cancel and await all active work for *key*.
|
||||
|
||||
Returns the total number of cancelled tasks + subagents.
|
||||
Returns the total number of cancelled tasks, subagents, and exec sessions.
|
||||
"""
|
||||
tasks = tuple(self._active_tasks.pop(key, set()))
|
||||
cancelled = sum(1 for t in tasks if not t.done() and t.cancel())
|
||||
@@ -798,7 +798,8 @@ class AgentLoop:
|
||||
with suppress(asyncio.CancelledError, Exception):
|
||||
await t
|
||||
sub_cancelled = await self.subagents.cancel_by_session(key)
|
||||
return cancelled + sub_cancelled
|
||||
exec_cancelled = await self._exec_session_manager.terminate_by_owner(key)
|
||||
return cancelled + sub_cancelled + exec_cancelled
|
||||
|
||||
async def discard_session(self, key: str) -> None:
|
||||
"""Stop active work for *key* and forget its cached session."""
|
||||
|
||||
Reference in New Issue
Block a user