From 770f5b6b60cc15b088ebfbfba9a3859a2d1220ba Mon Sep 17 00:00:00 2001 From: cfdaily Date: Fri, 29 May 2026 01:23:54 +0800 Subject: [PATCH] auto-sync: 2026-05-29 01:23:54 --- src/daemon/ticker.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/daemon/ticker.py b/src/daemon/ticker.py index f67b5aa..8abee77 100644 --- a/src/daemon/ticker.py +++ b/src/daemon/ticker.py @@ -403,7 +403,8 @@ class Ticker: # 检查 parent 自身状态:只有 done 状态的 parent 才触发 # (聚合后 parent 状态为 done 说明所有 sub 都完了) - if summary["parent_status"] != "done": + # BUG-2 fix: done 和 failed 都触发 review(failed 时优先判断重试/换人) + if summary["parent_status"] not in ("done", "failed"): continue # 检查 round_count 上限 @@ -426,11 +427,12 @@ class Ticker: # spawn 庞统 review review_prompt = self._build_review_prompt( - parent_task, summary, outputs, comments, new_round + parent_task, summary, outputs, comments, new_round, + project_id=project_id ) spawned = await self._spawn_pangtong_review( - parent_task, review_prompt, project_id + parent_task, review_prompt, project_id, new_round=new_round ) if spawned: reviewed.append(parent_id) @@ -445,7 +447,8 @@ class Ticker: def _build_review_prompt(self, parent_task, summary: dict, outputs: list, comments: list, - round_num: int) -> str: + round_num: int, + project_id: str = "") -> str: """构建庞统 review prompt(§4.2 三问框架)""" goal = parent_task.description or parent_task.title must_haves = parent_task.must_haves or "{}" @@ -494,20 +497,24 @@ class Ticker: {f'有 {summary["failed"]} 个 sub task failed,优先判断是应该重试、换人、还是调整方案。' if summary['failed'] > 0 else '无失败'} ### 你可以 -- 创建新一轮 sub tasks(通过 API: POST /api/projects/{{pid}}/tasks) +- 创建新一轮 sub tasks(通过 API: POST /api/projects/{project_id}/tasks) - 调整 goal(更新 parent task description/must_haves) - 标记完成(如果 goal 已达成,回复 GOAL_ACHIEVED) Round 上限: {self.MAX_ROUNDS}(当前第 {round_num} 轮) + +Project ID: {project_id} """ async def _spawn_pangtong_review(self, parent_task, review_prompt: str, - project_id: str) -> bool: + project_id: str, + new_round: int = 0) -> bool: """Spawn 庞统进行 review""" try: agent_id = "pangtong-fujunshi" - session_id = f"review-{parent_task.id}-r{parent_task.round_count + 1}" + # BUG-1 fix: 用传入的 new_round,不依赖 parent_task.round_count(已递增) + session_id = f"review-{parent_task.id}-r{new_round}" # 用 spawner.spawn_full_agent 直接 spawn result = await self.spawner.spawn_full_agent(