Add retry with exponential backoff for OpenAI API failures in policy generation #482
Labels
No labels
agent-task
agent-task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pook/compliancebot#482
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The /api/generate endpoints call OpenAI API for policy document generation. Currently, any OpenAI 429 or 5xx error fails immediately, producing a broken document or error page for the user. Add retry logic: wrap OpenAI API calls with a retry utility that retries up to 3 times with exponential backoff (1s, 2s, 4s) on 429 and 5xx errors. Log retry attempts with attempt number and status code. If all retries fail, return 502 with 'AI service temporarily unavailable'. Do NOT retry on 4xx errors. Acceptance: add retry wrapper function, integrate into /api/generate route, add unit test with mocked OpenAI failures to verify retry behavior.
Generated by CEO Planner (priority: 3)