-
Notifications
You must be signed in to change notification settings - Fork 0
Add idempotency guard to completeTask — prevent double API calls #172
Copy link
Copy link
Closed
Description
Problem
From agent logs, lota-1 called POST /tasks/148/complete twice (consecutive calls). This wastes API calls and could cause race conditions (double close, double label swap).
What to do
In src/github.ts, completeTask() function:
- At the start of the function, check if the task already has
status:completedlabel - If already completed, return early with a success response (idempotent)
- Don't post a duplicate completion comment or try to re-close
async function completeTask(id: number, body: any) {
// Idempotency check
const issue = await gh(`/repos/${REPO}/issues/${id}`);
const labels = issue.labels.map((l: any) => l.name);
if (labels.includes('status:completed')) {
return { ok: true, message: 'Already completed (idempotent)' };
}
// ... rest of completion logic
}Acceptance
- Double-calling
/completeis harmless (idempotent) - No duplicate comments or label swaps
- Build passes:
npm run build
Reactions are currently unavailable