Skip to content

feat: add retry logic with exponential backoff and Retry-After support#21

Open
MChorfa wants to merge 1 commit intoanthropics:mainfrom
MChorfa:feat/retry-logic
Open

feat: add retry logic with exponential backoff and Retry-After support#21
MChorfa wants to merge 1 commit intoanthropics:mainfrom
MChorfa:feat/retry-logic

Conversation

@MChorfa
Copy link
Copy Markdown

@MChorfa MChorfa commented Apr 9, 2026

Adds configurable retry mechanism for failed API requests. New --max-retries flag (default: 3). Respects Retry-After headers. Full test coverage.

@MChorfa MChorfa requested a review from a team as a code owner April 9, 2026 03:20
Copy link
Copy Markdown
Collaborator

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! A --max-retries option sounds good to me, but the Go SDK already supports a MaxRetries option that respects Retry-After etc. The CLI shouldn't reimplement the retry logic on top.

@MChorfa MChorfa force-pushed the feat/retry-logic branch from 701c67f to 731edf0 Compare May 1, 2026 19:54
@MChorfa MChorfa force-pushed the feat/retry-logic branch from 731edf0 to e6a67f6 Compare May 1, 2026 20:13
@MChorfa
Copy link
Copy Markdown
Author

MChorfa commented May 1, 2026

Hi! I have updated the PR to use the SDK native option.WithMaxRetries() instead of the custom middleware.

Changes made:

  • Removed internal/retry package entirely (370 lines deleted)
  • Now using option.WithMaxRetries(int) from the SDK
  • The SDK handles exponential backoff, jitter, and Retry-After headers automatically

The --max-retries flag is preserved with the same semantics:

  • Default: 3 retries
  • Range: 0-10 (0 disables retries)

Tests pass (internal packages). Ready for re-review!

@MChorfa MChorfa requested a review from felixfbecker May 1, 2026 20:20
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.

2 participants