auto-sync: 2026-05-23 00:39:34

This commit is contained in:
cfdaily
2026-05-23 00:39:34 +08:00
parent 601eff13ef
commit 72027b7063
+27
View File
@@ -803,6 +803,33 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_
pass
return defaults
def _update_retry_counts(self, db_path: Optional[Path],
task_id: Optional[str], counts: dict):
"""将 retry counts 写回最新 task_attempt 的 metadata"""
if not db_path or not task_id:
return
try:
conn = get_connection(db_path)
try:
conn.execute("BEGIN IMMEDIATE")
row = conn.execute(
"SELECT rowid, metadata FROM task_attempts "
"WHERE task_id=? ORDER BY attempt_number DESC LIMIT 1",
(task_id,)
).fetchone()
if row:
meta = json.loads(row["metadata"]) if row["metadata"] else {}
meta.update(counts)
conn.execute(
"UPDATE task_attempts SET metadata=? WHERE rowid=?",
(json.dumps(meta), row["rowid"])
)
conn.commit()
finally:
conn.close()
except Exception:
logger.exception("Failed to update retry counts for task %s", task_id)
def _mark_task(self, db_path: Optional[Path], task_id: Optional[str],
status: str, detail: Optional[dict] = None):
"""标记任务状态(用于 failed/escalate"""