Uh oh!
There was an error while loading. Please reload this page.
fix(api): add configurable request retries - #3302
Conversation
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. Fixessimstudioai#3225
@jayy-77 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryAdded configurable HTTP retry support with exponential backoff for the API block and
The implementation is well-structured with proper error classification (avoiding retries on non-retryable errors like body size limits or blocked IPs) and configurable limits (max 10 retries). Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Start[Start Request] --> Config[Resolve Retry Config]
Config --> CheckMethod{Method Retryable?}
CheckMethod -->|GET/PUT/DELETE/HEAD| DefaultRetries[Default: 2 retries]
CheckMethod -->|POST/PATCH| CheckOverride{retryNonIdempotent?}
CheckOverride -->|true| UserRetries[Use user retries]
CheckOverride -->|false| NoRetries[0 retries]
DefaultRetries --> Loop[Start Attempt Loop]
UserRetries --> Loop
NoRetries --> Loop
Loop --> Attempt[Make HTTP Request]
Attempt --> Success{Success?}
Success -->|Response OK| Done[Return Response]
Success -->|Error Thrown| ErrorCheck{Retryable Error?}
Success -->|HTTP Error Status| StatusCheck{Retryable Status?}
ErrorCheck -->|Timeout/Network| CheckLast1{Last Attempt?}
ErrorCheck -->|Body Size/Blocked IP| Fail[Throw Error]
ErrorCheck -->|Other Error| Fail
StatusCheck -->|429 or 5xx| CheckLast2{Last Attempt?}
StatusCheck -->|4xx| Fail
CheckLast1 -->|Yes| Fail
CheckLast1 -->|No| Backoff1[Calculate Backoff Delay]
CheckLast2 -->|Yes| Fail
CheckLast2 -->|No| CheckRetryAfter{Retry-After Header?}
CheckRetryAfter -->|Yes| UseMax[Use max of backoff and Retry-After]
CheckRetryAfter -->|No| Backoff2[Calculate Backoff Delay]
Backoff1 --> Sleep1[Sleep with Delay]
UseMax --> Sleep2[Sleep with Delay]
Backoff2 --> Sleep2
Sleep1 --> Loop
Sleep2 --> Loop
Last reviewed commit: 543ddfb |
Summary
Retry-After) for timeouts/network failures, 429s, and 5xx responses.http_requesttool.Test plan
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres bun run test tools/index.test.tsDATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres bun run test tools/http/request.test.tsFixes#3225