auto-sync: 2026-05-25 13:20:31

This commit is contained in:
cfdaily
2026-05-25 13:20:31 +08:00
parent 50b5005c46
commit d9d8862706
+19
View File
@@ -625,6 +625,25 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_
async def _do_retry(self, session_id, agent_id, task_id, on_complete,
db_path, retry_field="retry_count"):
"""续杯:用同一 session_id 再 spawn 一次"""
# Bug-6: 续杯前检查任务状态,已终态则跳过
if db_path and task_id:
try:
conn = get_connection(db_path)
try:
row = conn.execute(
"SELECT status FROM tasks WHERE id=?", (task_id,)
).fetchone()
if row and row["status"] in ("done", "failed", "cancelled", "review"):
logger.info("Retry skip: task %s already %s (agent=%s)",
task_id, row["status"], agent_id)
# counter 仍然占用,通过 on_complete release
await self._do_on_complete_async(on_complete, agent_id, "task_already_done")
return
finally:
conn.close()
except Exception:
logger.warning("Retry status check failed for %s, proceeding", task_id)
# 直接读写 tasks 表的 retry_count(广播场景下所有 Agent 共享同一 tasks 记录)
# task_attempts metadata 的 retry_count 不可靠(多 Agent 互相覆盖)
if retry_field == "retry_count" and db_path and task_id: