[Agent] Issue #482: the apigenerate endpoints call openai ap #485

Closed
pook wants to merge 50 commits from feat/openai-retry-502 into main
Owner

Closes #482

Changes

feat: issue #482 the-apigenerate-endpoints-call-openai-ap (agent task liancebot482)

Acceptance Criteria

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)

Tokens: 35 in / 9574 out

Closes #482 ## Changes feat: issue #482 the-apigenerate-endpoints-call-openai-ap (agent task liancebot482) ## Acceptance Criteria 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)* Tokens: 35 in / 9574 out
Route handlers for /generate/* now catch retryable errors after all
retries are exhausted and return 502 "AI service temporarily unavailable"
instead of letting the error propagate as a generic failure. Retry log
messages now include the HTTP status code for easier debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: issue #482 the-apigenerate-endpoints-call-openai-ap (agent task liancebot482)
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
d9d05fc521
pook closed this pull request 2026-04-10 21:14:58 -04:00
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!485
No description provided.