Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(ttse): isolate TTSE cleanup from skill-evolution watcher cancel

unknown08f77c992301
diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
index 9e5be22769..e2bfe07719 100644
--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
@@ -2553,6 +2553,7 @@ class JiuWenSwarmDeepAdapter:
self._avatar_rail: Any = None
self._tool_cards = None
self._evolution_watcher_tasks: set[asyncio.Task] = set()
+ self._ttse_cleanup_tasks: set[asyncio.Task] = set()
self._sys_operation = None
self._sys_operation_card: SysOperationCard | None = None
# 专供 rail 使用的本地 sysop(忽略沙箱配置;与 self._sys_operation 可不同)
@@ -20179,8 +20180,8 @@ class JiuWenSwarmDeepAdapter:
ttse_task = asyncio.create_task(
self._cleanup_ttse_background_tasks(rid, session_id)
)
- ttse_task.add_done_callback(self._on_evolution_watcher_done)
- self._evolution_watcher_tasks.add(ttse_task)
+ ttse_task.add_done_callback(self._on_ttse_cleanup_done)
+ self._ttse_cleanup_tasks.add(ttse_task)
if _debug_logger is not None:
if run_failure is not None:
_debug_logger.end_run(
@@ -22694,6 +22695,14 @@ class JiuWenSwarmDeepAdapter:
except Exception as exc:
logger.warning("[JiuWenSwarmDeepAdapter] evolution watcher task exception: %s", exc)
+ def _on_ttse_cleanup_done(self, task: asyncio.Task) -> None:
+ """Drop a finished TTSE cleanup task and log a normal failure."""
+ self._ttse_cleanup_tasks.discard(task)
+ try:
+ task.result()
+ except Exception as exc:
+ logger.warning("[JiuWenSwarmDeepAdapter] TTSE cleanup task exception: %s", exc)
+
@staticmethod
def _is_approval_event(evt) -> bool:
"""Check whether an OutputSchema event is an approval request."""