Skip to content

feat(providers): provider-aware retry with exponential backoff and rate-limit handling #23

Open

Description

@EngineerProjects

Summary

Providers like Anthropic and OpenAI return 429 Too Many Requests with
a retry-after header. The current retry logic does not honour this header
and uses fixed delays. This leads to wasted retries and unnecessary failures
on long multi-agent runs.

Scope

  • Read retry-after / x-ratelimit-reset-requests headers on 429 responses
  • Exponential backoff with jitter for 5xx errors
  • Per-provider retry config: max retries, base delay, max delay
  • Expose config.RetryPolicy in ClientConfig

Proposed config

type RetryPolicy struct {
    MaxRetries    int           // default 3
    BaseDelay     time.Duration // default 1s
    MaxDelay      time.Duration // default 60s
    HonorRetryAfter bool        // default true
}

Acceptance criteria

  • RetryPolicy struct in pkg/sdk
  • retry-after header parsed and respected (sleep until reset time)
  • Exponential backoff with ±10% jitter for 5xx
  • Unit tests: 429 with header → correct sleep duration; 5xx → backoff sequence
  • No retry on 4xx errors other than 429

Activity

  1. added
    enhancement
    core
    on Jun 4, 2026
  2. EngineerProjects commented on Oct 3, 2026

    @EngineerProjects
    CollaboratorAuthor

    Status check (v1.2.64): partly done. internal/providers/retry parses the Retry-After header (ParseRetryAfterHeader) and uses exponential backoff with jitter, and providers.Client has SetRetryConfig. Not done: the RetryPolicy type exposed in the SDK ClientConfig, and per-provider settings. Leaving open for those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions