Skip to content

fix: add retry with exponential backoff for Anthropic API overloaded errors#733

Merged
bokelley merged 2 commits into
mainfrom
bokelley/claude-overload-retry
Jan 12, 2026
Merged

fix: add retry with exponential backoff for Anthropic API overloaded errors#733
bokelley merged 2 commits into
mainfrom
bokelley/claude-overload-retry

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • Adds retry logic with exponential backoff for Anthropic API transient errors (overloaded_error 529, connection errors, rate limits, 500+ server errors)
  • Shows retry status to users in Slack ("API is busy, retrying (1/3)...") and web chat (SSE retry events)
  • Provides user-friendly error messages when retries are exhausted (e.g., "The AI service is currently experiencing high demand")

Changes

  • New: server/src/utils/anthropic-retry.ts - Core retry utility with withRetry, withStreamRetry, RetriesExhaustedError
  • Modified: server/src/addie/claude-client.ts - Added retry wrapper for API calls and retry event yielding in streaming
  • Modified: server/src/addie/bolt-app.ts - Handle retry events to update Slack status
  • Modified: server/src/routes/addie-chat.ts - Send SSE retry events to web clients
  • New: tests/utils/anthropic-retry.test.ts - Comprehensive tests (24 test cases)

Test plan

  • Unit tests pass (24 retry-specific tests)
  • Full test suite passes (211 tests)
  • TypeScript compiles without errors
  • Code review completed and feedback addressed

🤖 Generated with Claude Code

bokelley and others added 2 commits January 12, 2026 13:40
…errors

The Addie bot was failing with overloaded_error (529) from Anthropic API
during high load, causing message processing to fail silently.

Changes:
- Add anthropic-retry.ts utility with isRetryableError and withRetry helpers
- Wrap processMessage API call with withRetry (3 retries, exponential backoff)
- Add inline retry loop to processMessageStream (only retries before content streams)
- Support retryable errors: overloaded_error, 500+, 429, APIConnectionError
- Add comprehensive tests for retry behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- withStreamRetry now throws RetriesExhaustedError for consistency
- Streaming path in claude-client wraps exhausted retries in RetriesExhaustedError
- Added tests for withStreamRetry (yields, retries, non-retryable, exhausted)
- Added test for RetriesExhaustedError.cause containing original error
- Added empty changeset

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit 3d176c2 into main Jan 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant