fix(core): honor Retry-After for model retries#1279
Conversation
🦋 Changeset detectedLatest commit: 7be7e2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds Retry-After support: a helper parses ChangesRetry-After Header Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/agent/agent.ts`:
- Around line 5752-5759: The Retry-After delay calculation can exceed Node's max
timer (2,147,483,647 ms) causing setTimeout to clamp to ~1ms; introduce a
MAX_NODE_TIMER constant (2147483647) and clamp computed delays to that limit in
getRetryAfterDelayMs and where retryDelayMs is ultimately assigned before
calling setTimeout (refer to function getRetryAfterDelayMs and the variable
retryDelayMs). Ensure both the seconds-parsed branch and the Date-parsed branch
return Math.min(calculatedDelay, MAX_NODE_TIMER) and that the final retryDelayMs
is similarly clamped so setTimeout never receives a value > MAX_NODE_TIMER.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9eebe398-7d11-4c5c-9b99-6d8e62d3d21e
📒 Files selected for processing (3)
.changeset/friendly-agents-wait.mdpackages/core/src/agent/agent.spec.tspackages/core/src/agent/agent.ts
Summary\n- read provider Retry-After headers when VoltAgent retries failed model calls\n- use Retry-After seconds or HTTP-date values before falling back to exponential backoff\n- add a focused agent retry test for 429 provider errors\n\n## Verification\n- corepack pnpm install --ignore-scripts --frozen-lockfile\n- corepack pnpm --filter @voltagent/internal build\n- corepack pnpm exec vitest run src/agent/agent.spec.ts -t "Retry-After"
Summary by cubic
Honor provider
Retry-Afterduring model retries. Wait the server-recommended delay and clamp oversized values to Node’s max timer to avoid overflow.Retry-After(seconds or HTTP-date) from error headers and use it for the next attempt.Written for commit 7be7e2c. Summary will update on new commits.
Summary by CodeRabbit
New Features
Retry-Afterheaders when retrying failed model requests.Bug Fixes
Retry-Aftervalues to a safe maximum to prevent timer overflow.Tests
Retry-After, and clamping behavior.Chores