From c9cdd2f2d4504e68c043a35b6b57b8c28957d22d Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 17 May 2026 18:36:46 +0800 Subject: [PATCH] auto-sync: 2026-05-17 18:36:46 --- src/daemon/dispatcher.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/daemon/dispatcher.py b/src/daemon/dispatcher.py index b167625..5f84fb5 100644 --- a/src/daemon/dispatcher.py +++ b/src/daemon/dispatcher.py @@ -227,6 +227,25 @@ class Dispatcher: "reason": "Unknown dispatch level", } + def _build_retry_context(self, task: Task) -> str: + """构建重试上下文(前轮产出摘要 + 审查意见) + + 如果任务是从 failed/pending 重新调度(有历史 attempts), + 注入前轮的产出摘要和审查意见,让 Agent 知道上轮哪里不对。 + """ + if not hasattr(task, 'retry_count') or (task.retry_count or 0) == 0: + return "" + + parts = ["## ⚠️ 重试上下文(上次执行失败,请注意以下反馈)"] + parts.append(f"这是第 {task.retry_count + 1} 次尝试。上次执行的问题:") + + # 尝试从 task 的 metadata 获取上次失败原因 + if hasattr(task, 'notes') and task.notes: + parts.append(f"上轮说明: {task.notes}") + + parts.append("请仔细检查上次的错误,避免重复犯错。") + return "\n".join(parts) + def _build_message(self, task: Task, action_type: str) -> str: """构建给 Agent 的消息""" parts = [f"Task: {task.title}"]