address greptile review feedback (greploop iteration 6)

- Exclude expired tasks from claim_due return value to prevent agents
  from receiving expired task payloads

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

View file

@ -326,6 +326,7 @@ async def claim_due(
if not rows:
return []
expired_task_ids: set = set()
async with tx.batch_() as batcher:
for r in rows:
expires_at = r["expires_at"]
@ -339,6 +340,7 @@ async def claim_due(
if expires_at <= now:
new_status = "expired"
new_next = r["next_run_at"]
expired_task_ids.add(r["task_id"])
elif r["fire_once"]:
new_status = "fired"
new_next = r["next_run_at"]
@ -371,4 +373,5 @@ async def claim_due(
"scheduled_for": r["next_run_at"],
}
for r in rows
if r["task_id"] not in expired_task_ids
]