feat: add timeout guard for OpenAI generation API calls #159

Closed
pook wants to merge 2 commits from feat/openai-timeout-guard into main
Owner

Summary

  • Wraps OpenAI chat.completions.create with AbortController + configurable timeout (default 30s via GENERATION_TIMEOUT_MS env var)
  • On timeout, throws GenerationTimeoutError caught by global error handler → returns 504 Gateway Timeout with request ID for debugging
  • Adds 5 unit tests covering: success path, timeout trigger, default timeout, custom env var timeout, and non-timeout error passthrough

Test plan

  • bun test packages/api/tests/unit/llm-timeout.test.ts — 5/5 pass
  • TypeScript type check clean (only pre-existing TS6059 rootDir warnings)
  • E2E verification with running API server

Closes #63
Closes #136

🤖 Generated with Claude Code

## Summary - Wraps OpenAI `chat.completions.create` with `AbortController` + configurable timeout (default 30s via `GENERATION_TIMEOUT_MS` env var) - On timeout, throws `GenerationTimeoutError` caught by global error handler → returns **504 Gateway Timeout** with request ID for debugging - Adds 5 unit tests covering: success path, timeout trigger, default timeout, custom env var timeout, and non-timeout error passthrough ## Test plan - [x] `bun test packages/api/tests/unit/llm-timeout.test.ts` — 5/5 pass - [x] TypeScript type check clean (only pre-existing TS6059 rootDir warnings) - [ ] E2E verification with running API server Closes #63 Closes #136 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Wrap OpenAI chat completion calls with AbortController to prevent
indefinite hangs that block the event loop. On timeout, returns 504
Gateway Timeout with request ID for debugging. Timeout is configurable
via GENERATION_TIMEOUT_MS env var (default 30000ms).

Closes #63
Closes #136

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

Closed 2026-04-10 during pipeline triage.

Merge conflicts with current main were blocking the CEO agent's backlog view. The compliancebot repo had ~60 open PRs and 141 open agent-task issues. CEO couldn't see progress and kept duplicating work due to a git-push race in agent-worker (now fixed — runId threaded through dispatch pipeline for unique branch names).

Reopen / resubmit against current main if the work is still relevant. Shim /shim/ceo route now injects open issues + PRs into the CEO prompt and refuses dispatch when backlog exceeds 20.

Closed 2026-04-10 during pipeline triage. Merge conflicts with current main were blocking the CEO agent's backlog view. The compliancebot repo had ~60 open PRs and 141 open agent-task issues. CEO couldn't see progress and kept duplicating work due to a git-push race in agent-worker (now fixed — runId threaded through dispatch pipeline for unique branch names). Reopen / resubmit against current main if the work is still relevant. Shim `/shim/ceo` route now injects open issues + PRs into the CEO prompt and refuses dispatch when backlog exceeds 20.
pook closed this pull request 2026-04-10 15:08:13 -04:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!159
No description provided.