From 00a7e776299455e55ce7eece1a8613192dc85299 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 15 Aug 2026 00:27:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20diagnose=5Fproject=20=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E4=B8=AD=E4=BB=BB=E5=8A=A1=E8=BF=94=E5=9B=9E=20claimed=5Fby+?= =?UTF-8?q?=E5=BF=83=E8=B7=B3=E9=99=88=E6=97=A7=E5=BA=A6=EF=BC=8Cagent=20?= =?UTF-8?q?=E5=8F=AF=E7=9B=B4=E6=8E=A5=E8=AF=86=E5=88=AB=E5=83=B5=E5=B0=B8?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_service/agent_loop_v2.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index f95ec9e..0c8de8d 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -856,6 +856,31 @@ class AgentExecutor: for sr in (submitted_rows or []): lines.append(f" - [{getattr(sr, 'role', '?')}] {getattr(sr, 'title', '')} (id={getattr(sr, 'id', '')})") + # 运行中任务明细:claimed_by + 心跳陈旧度,帮助 agent 直接识别僵尸任务 + # (进程崩溃/协程挂起后心跳不再更新,超时即疑似僵尸,会被 poller 自动回收重跑) + if rc: + running_rows = await sor.sqlExe( + "SELECT id, title, role, claimed_by, " + "TIMESTAMPDIFF(MINUTE, updated_at, NOW()) AS mins " + "FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='running' " + "ORDER BY updated_at ASC LIMIT 10", + {"pid": pid}) + lines.append("运行中任务:") + for rr in (running_rows or []): + rrole = getattr(rr, 'role', '?') + rtitle = getattr(rr, 'title', '') + rid = getattr(rr, 'id', '') + rcb = getattr(rr, 'claimed_by', '') or '' + try: + mins = int(getattr(rr, 'mins', 0) or 0) + except (TypeError, ValueError): + mins = 0 + if mins >= 10: + flag = f"⚠️心跳超时{mins}分钟(疑似僵尸,将被回收重跑)" + else: + flag = f"已运行{mins}分钟" + lines.append(f" - [{rrole}] {rtitle} (id={rid}) | {flag} | claimed_by={rcb[:8]}") + return "\n".join(lines) async def _t_list_deliverables(self, sor, p, pid):