Adds LanguageModelRateLimitingPlugin. Closes #1309#1324
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a new LanguageModelRateLimitingPlugin to enforce per-window token quotas and provide throttling or custom responses on limit exceed.
- Introduces JSON schemas for plugin configuration and custom response files
- Implements the core plugin logic and a file-watcher loader for custom responses
- Updates OpenAIModels classes from abstract to concrete to support deserialization
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| schemas/v1.0.0/languagemodelratelimitingplugin.schema.json | Defines config properties for the rate-limiting plugin |
| schemas/v1.0.0/languagemodelratelimitingplugin.customresponsefile.schema.json | Defines schema for custom error responses |
| DevProxy.Plugins/Behavior/LanguageModelRateLimitingPlugin.cs | Implements rate-limiting, token tracking, throttle/custom responses |
| DevProxy.Plugins/Behavior/LanguageModelRateLimitingCustomResponseLoader.cs | Loads and watches custom response files |
| DevProxy.Abstractions/LanguageModel/OpenAIModels.cs | Changed OpenAIRequest/Response from abstract classes to concrete classes |
Comments suppressed due to low confidence (4)
schemas/v1.0.0/languagemodelratelimitingplugin.schema.json:4
- Add a "required" array to enforce mandatory properties (e.g., "promptTokenLimit", "completionTokenLimit", "resetTimeWindowSeconds") to ensure configuration completeness.
"type": "object",
schemas/v1.0.0/languagemodelratelimitingplugin.customresponsefile.schema.json:5
- Define a "required" array (e.g., ["body", "statusCode"]) so consumers must include these mandatory fields in custom response files.
"type": "object",
DevProxy.Plugins/Behavior/LanguageModelRateLimitingPlugin.cs:38
- Consider adding unit tests covering rate limiting logic (token decrement, reset window, throttle/custom response) to ensure behavior is validated and prevent regressions.
public sealed class LanguageModelRateLimitingPlugin(
DevProxy.Plugins/Behavior/LanguageModelRateLimitingPlugin.cs:155
- The empty list literal '[]' may not compile or infer the correct type for headersList. Use 'new List()' to explicitly create an empty List.
[];
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…guageModelRateLimitingPlugin
Collaborator
garrytrinder
approved these changes
Jul 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds LanguageModelRateLimitingPlugin. Closes #1309
Test:
devproxyrc.json:
{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json", "plugins": [ { "name": "LanguageModelRateLimitingPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll", "configSection": "languageModelRateLimitingPlugin" } ], "urlsToWatch": [ "*" ], "languageModelRateLimitingPlugin": { "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/languagemodelratelimitingplugin.schema.json", "promptTokenLimit": 500, "completionTokenLimit": 500, "resetTimeWindowSeconds": 300 }, "logLevel": "information", "newVersionNotification": "stable", "showSkipMessages": true, "showTimestamps": true, "validateSchemas": true, "asSystemProxy": false }Call ollama a few times:
Roughly third request should fail with a 429
The schema validation error on startup is expected because the schema is in this PR.