auto-sync: 2026-05-17 19:08:06

This commit is contained in:
cfdaily
2026-05-17 19:08:06 +08:00
parent 03ccc49390
commit d90ad9f305
+19 -4
View File
@@ -255,7 +255,7 @@ class Dispatcher:
"""构建重试上下文(前轮产出摘要 + 审查意见)
如果任务是从 failed/pending 重新调度(有历史 attempts),
注入前轮的产出摘要和审查意见,让 Agent 知道上轮哪里不对。
注入前轮的失败原因,让 Agent 知道上轮哪里不对。
"""
if not hasattr(task, 'retry_count') or (task.retry_count or 0) == 0:
return ""
@@ -263,9 +263,24 @@ class Dispatcher:
parts = ["## ⚠️ 重试上下文(上次执行失败,请注意以下反馈)"]
parts.append(f"这是第 {task.retry_count + 1} 次尝试。上次执行的问题:")
# 尝试从 task 的 metadata 获取上次失败原因
if hasattr(task, 'notes') and task.notes:
parts.append(f"上轮说明: {task.notes}")
# 从 task_attempts 查上次 attempt 的 summary/outcome
if hasattr(self, '_queries') and self._queries:
try:
rows = self._queries.conn.execute(
"SELECT outcome, summary, agent FROM task_attempts "
"WHERE task_id = ? ORDER BY attempt_number DESC LIMIT 1",
(task.id,)
).fetchall()
if rows:
outcome, summary, agent = rows[0]
if outcome:
parts.append(f"上轮结果: {outcome}")
if summary:
parts.append(f"上轮说明: {summary}")
if agent:
parts.append(f"上轮执行者: {agent}")
except Exception:
pass
parts.append("请仔细检查上次的错误,避免重复犯错。")
return "\n".join(parts)