Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/resilient-openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ broader Moonbeam service.

| Feature | Default |
| -------------------------------------------------------- | ---------------------------------- |
| Per-request timeout | 10 s |
| Per-request timeout | 30 s |
| Automatic retries with exponential backoff + full jitter | 3 retries |
| `Retry-After` header honored on 429 responses | yes |
| Circuit breaker | opens after 5 consecutive failures |
Expand Down Expand Up @@ -47,7 +47,7 @@ All variables are optional. Defaults are shown.
| Variable | Default | Description |
| ------------------------------- | ------- | ------------------------------------------------------------- |
| `FEATURE_FLAG_RESILIENT_OPENAI` | `true` | Set to `false` to bypass the wrapper entirely. |
| `OPENAI_TIMEOUT_MS` | `10000` | Maximum ms to wait for a single request before aborting. |
| `OPENAI_TIMEOUT_MS` | `30000` | Maximum ms to wait for a single request before aborting. |
| `OPENAI_RETRIES` | `3` | Maximum retry attempts on transient errors. |
| `OPENAI_BACKOFF_BASE_MS` | `500` | Base interval (ms) for exponential backoff with full jitter. |
| `CIRCUIT_BREAKER_FAILURES` | `5` | Consecutive failures needed to open the circuit. |
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/config/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const parseIntWithDefault = (value: string | undefined, defaultValue: number): n
};

export const getOpenAIClientConfig = (): OpenAIClientConfig => ({
timeoutMs: Math.max(1, parseIntWithDefault(process.env.OPENAI_TIMEOUT_MS, 10_000)),
timeoutMs: Math.max(1, parseIntWithDefault(process.env.OPENAI_TIMEOUT_MS, 30_000)),
retries: Math.max(0, parseIntWithDefault(process.env.OPENAI_RETRIES, 3)),
backoffBaseMs: Math.max(0, parseIntWithDefault(process.env.OPENAI_BACKOFF_BASE_MS, 500)),
circuitBreakerFailures: Math.max(1, parseIntWithDefault(process.env.CIRCUIT_BREAKER_FAILURES, 5)),
Expand Down
Loading