Skip to content

Conversation

@sujal12344
Copy link

@sujal12344 sujal12344 commented Oct 25, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

Currently, VoltAgent has no built-in mechanism to control the frequency of LLM calls and tool executions. This can lead to:

  • Exceeding API rate limits from LLM providers (OpenAI, Anthropic, Google, etc.)
  • Unexpected API throttling or account suspension
  • Uncontrolled costs in production environments
  • Poor resource management in multi-tenant scenarios
  • No way to implement custom usage quotas

Users must implement rate limiting manually in their application code, which is:

  • Error-prone and inconsistent across different agents
  • Difficult to test and maintain
  • Not integrated with VoltAgent's observability features

What is the new behavior?

  1. Configurable Rate Limiting

    • Control LLM calls globally or per provider
    • Limit tool executions individually
    • Support for requests-per-minute constraints
  2. Flexible Strategies

    • Fixed Window Counter (MVP)
    • Option to throw error immediately or delay until quota resets
  3. Multi-Scope Support

    • Global LLM limits
    • Provider-specific limits (OpenAI, Anthropic, etc.)
    • Tool-specific limits

Example Project (examples/with-rate-limiting/)

  • 6 working examples demonstrating all features:
    1. Basic LLM rate limiting (throw strategy)
    2. Delay strategy (auto-wait behavior)
    3. Provider-specific limits
    4. Tool-specific limits
    5. Combined LLM + tool limits
    6. Monitoring and statistics
  • Ready-to-run with Google Gemini API

fixes (issue) #5

Screenshots with running project with rate limiting

WhatsApp Image 2025-10-25 at 14 56 35_372aa8ec

WhatsApp Image 2025-10-25 at 15 01 11_19a5271c

WhatsApp Image 2025-10-25 at 15 35 20_a339b82a

WhatsApp Image 2025-10-25 at 15 44 20_00911578

WhatsApp Image 2025-10-25 at 15 46 36_d414a9c6

WhatsApp Image 2025-10-25 at 15 47 45_d80b69db

@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2025

⚠️ No Changeset found

Latest commit: 8de4af4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sujal12344 sujal12344 changed the title Feat/rate limit implementation feat/rate limit implementation Oct 25, 2025
@sujal12344
Copy link
Author

sujal12344 commented Oct 25, 2025

Hey @omeraplak @marinoska @necatiozmen , I’ve submitted a PR — #742
Could you please review it and share your feedback when you get a chance?

@sujal12344 sujal12344 mentioned this pull request Oct 25, 2025
@omeraplak
Copy link
Member

Hey @sujal12344 ,
Thank you! I'll review it soon

@omeraplak
Copy link
Member

Hey @sujal12344 , thanks a lot for the PR! 🔥

I have a couple of questions:

  1. Since we define rateLimits on the Agents and each agent has only one model, how does the providers field under rateLimits work?
rateLimits: {
  providers: {
    openai: {
      maxRequestsPerMinute: 5,
      onExceeded: "throw"
    },
    anthropic: {
      maxRequestsPerMinute: 3,
      onExceeded: "delay"
    }
  }
}

Is this meant for future support when dynamic providers are added?

  1. When defining rate limits for tools, is there a way to add IntelliSense support? That way, tool names could be resolved dynamically.
  2. It would be nice if the user could be notified via a hook when a rate limit is reached.
    Right now, onExceeded returns a decision, but maybe there could also be a hook with the same name?
  3. What do you think about defining a global rate limit through the new VoltAgent() instance itself?

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