Skip to content

feat(api): retry configuration for api block#3329

Merged
waleedlatif1 merged 7 commits intostagingfrom
fix/api-block-retries-3225
Feb 25, 2026
Merged

feat(api): retry configuration for api block#3329
waleedlatif1 merged 7 commits intostagingfrom
fix/api-block-retries-3225

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

add configurable request retries to api block

Fixes #3225

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 25, 2026 8:01am

Request Review

jayy-77 and others added 2 commits February 24, 2026 19:32
The API block docs described automatic retries, but the block didn't expose any retry controls and requests were executed only once.

This adds tool-level retry support with exponential backoff (including Retry-After support) for timeouts, 429s, and 5xx responses, exposes retry settings in the API block and http_request tool, and updates the docs to match.

Fixes #3225
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

This PR adds configurable retry logic to the API block, allowing users to specify retry attempts, delays, and exponential backoff for handling transient failures like timeouts, rate limits (429), and server errors (5xx).

Key changes:

  • Adds four new advanced configuration options: retries count, initial delay, max delay, and non-idempotent retry flag
  • Implements exponential backoff with jitter for retry delays
  • Respects Retry-After headers from 429 responses
  • Only retries idempotent methods (GET, HEAD, PUT, DELETE) by default; POST/PATCH require explicit opt-in
  • Properly consumes response bodies before retrying to prevent resource leaks
  • Includes comprehensive test coverage for all retry scenarios

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations for production usage
  • Well-implemented retry logic with proper safeguards (max retry limits, body consumption, idempotency checks). Previous resource leak issue has been addressed. Comprehensive test coverage validates all retry scenarios. Default of 0 retries ensures no behavior change for existing users.
  • Pay close attention to apps/sim/tools/index.ts for the retry implementation logic

Important Files Changed

Filename Overview
apps/sim/tools/index.ts Implements retry logic with exponential backoff, handles idempotent/non-idempotent methods, and consumes response bodies before retry
apps/sim/tools/http/request.ts Adds retry configuration parameters with appropriate defaults and visibility settings
apps/sim/tools/index.test.ts Comprehensive test coverage for retry logic including 5xx, 429, timeouts, idempotency, and Retry-After header handling

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[API Request] --> B{Retry Config Enabled?}
    B -->|No| C[Execute Request Once]
    B -->|Yes| D{Method Idempotent?}
    D -->|Yes| E[Execute Request]
    D -->|No| F{retryNonIdempotent?}
    F -->|No| C
    F -->|Yes| E
    E --> G{Request Successful?}
    G -->|Yes| H[Return Response]
    G -->|No| I{Retryable Error?}
    I -->|No| J[Return Error]
    I -->|Yes| K{Attempts Remaining?}
    K -->|No| J
    K -->|Yes| L{429 with Retry-After?}
    L -->|Yes| M{Retry-After > maxDelay?}
    M -->|Yes| J
    M -->|No| N[Wait Retry-After]
    L -->|No| O[Calculate Backoff]
    N --> E
    O --> P[Wait with Jitter]
    P --> E
    C --> Q{Success?}
    Q -->|Yes| H
    Q -->|No| J
Loading

Last reviewed commit: 3b1fd86

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit 43c0f5b into staging Feb 25, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/api-block-retries-3225 branch February 25, 2026 08:13
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