From 4be319b52229acc6f83a78fd4163529afeb413a9 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Tue, 26 May 2026 08:32:08 +0800 Subject: [PATCH] auto-sync: 2026-05-26 08:32:08 --- src/daemon/ticker.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/daemon/ticker.py b/src/daemon/ticker.py index 0c8c821..9ecccc1 100644 --- a/src/daemon/ticker.py +++ b/src/daemon/ticker.py @@ -875,17 +875,32 @@ class Ticker: except (ValueError, TypeError): pass - # v2.7.2: 进程存活性检查 — counter 占用但进程已死的光底 + # v2.7.2: 进程存活性检查 — counter 占用但进程已死的兜底 if self.spawner and self.counter: for agent_id in list(self.counter.active_agents.keys()): session_info = self.spawner.get_session_by_agent(agent_id) if not session_info: continue pid = session_info.get("pid") + task_id_check = session_info.get("task_id") if pid and not self._is_pid_alive(pid): - logger.warning("Agent %s process dead (pid=%d), releasing counter", + logger.warning("Agent %s process dead (pid=%d), releasing counter + push back pending", agent_id, pid) self.counter.release(agent_id) + # 推回 pending 让 ticker 重新 dispatch + if task_id_check and db_path: + try: + conn = get_connection(db_path) + try: + self._transition_status( + conn, task_id_check, "pending", + agent="daemon", + detail={"reason": "process_dead", "pid": pid}, + ) + finally: + conn.close() + except Exception: + logger.exception("Failed to push back task %s", task_id_check) return reclaimed