Skip to content

fix(python): add random jitter to exponential retry backoff calculation - #43

Open
Adityakk9031 wants to merge 1 commit into
RightNow-AI:mainfrom
Adityakk9031:#42
Open

Adityakk9031 wants to merge 1 commit into
RightNow-AI:mainfrom
Adityakk9031:#42

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Aug 2, 2026 •

Copy link
Copy Markdown

close #42

Description

Fixes issue #42 in the Python SDK (runinfra):

  • Missing Retry Jitter: _retry_delay_seconds calculated deterministic exponential backoff delays (base_seconds * (2 ** max(0, attempt - 1))) without adding random jitter. When upstream transient errors (such as 429 Rate Limit or 503 Service Unavailable) occurred across multiple client processes, all workers retried in exact lockstep at identical intervals (thundering herd).
  • Resolution: Updated _retry_delay_seconds to include random full jitter (exponential + random.random() * base_seconds), matching the TypeScript SDK implementation (@runinfra/sdk).

Testing & Verification

  • Added test_retry_delay_seconds_includes_jitter to python/tests/test_runinfra_sdk.py.
  • Updated mock sleep assertions in retry tests to verify delay ranges with jitter bounds (base_seconds <= delay <= 2 * base_seconds).
  • Ran full Python unit test suite: 159/159 tests passed (Ran 159 tests in 0.638s - OK).
  • Ran node scripts/verify-version-sync.mjs: Version sync intact at 0.2.0.

@Adityakk9031

Copy link
Copy Markdown
Author

@jaberjaber23 have a look

This branch has not been deployed

No deployments
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.

[bug]: Python SDK retry backoff calculation omits random jitter

1 participant