Files
d02c10b399 feat: configure API retry backoff (#370) (#1095)
* feat: configure API retry backoff

Add OpenClaude-branded retry controls for retryable API failures.

- Replace the old CLAUDE_CODE_MAX_RETRIES config with OPENCLAUDE_MAX_RETRIES

- Allow OPENCLAUDE_MAX_RETRIES=0 to disable retries after the initial request

- Cap retry attempts at 100 and invalid values fall back to the default of 10

- Add OPENCLAUDE_RETRY_DELAY_MS to configure the exponential backoff base for APIs that omit Retry-After

- Keep Retry-After precedence over configured retry delay

- Document both settings in .env.example and advanced setup docs

- Add focused retry configuration tests for defaults, invalid values, caps, zero retries, configured delay, and Retry-After precedence

Validation:

- bun test src/services/api/withRetry.test.ts

- bun run build

* Honor legacy max retries env var

Add compatibility fallback from CLAUDE_CODE_MAX_RETRIES when OPENCLAUDE_MAX_RETRIES is unset.

Document the deprecated fallback and cover precedence behavior in retry configuration tests.

---------

Co-authored-by: JATMN <12479882+jatmn@users.noreply.github.com>
2026-05-25 19:27:07 +08:00
..