address greptile review feedback (greploop iteration 6 followup)

- Gate all report_task_result error-path writes on status=pending to
  prevent late error reports from mutating terminal-state tasks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Krrish Dholakia 2026-05-01 13:26:45 -07:00
parent 98aa9dc84f
commit ca0eae194c

View file

@ -189,15 +189,14 @@ async def report_task_result(
"consecutive_errors": new_count,
"last_error": reason,
}
where_clause: Dict[str, Any] = {
"task_id": task_id,
"owner_token": owner_token,
}
if new_count >= MAX_CONSECUTIVE_ERRORS:
update_data["status"] = "failed"
where_clause["status"] = "pending"
affected = await prisma_client.db.litellm_scheduledtasktable.update_many(
where=where_clause,
where={
"task_id": task_id,
"owner_token": owner_token,
"status": "pending",
},
data=update_data,
)
if affected == 0: