LanguageModelRateLimitingPlugin returns a billing error (insufficient_quota) instead of a rate limit error

Geschlossen Anfängerfreundlich
#1,911 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@waldekmastykarz arbeitet bereits daran.

Seit 04.10.2026.

  • #1912 von @waldekmastykarz — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
82/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
csharp
Bereich
devtools

Rechercherichtung

Beginne in DevProxy.Plugins/Behavior/LanguageModelRateLimitingPlugin.cs und vergleiche die erwartete Fehlerstruktur mit dem openai-throttling-Preset in pnp/proxy-samples. Als abgeschlossen gilt die Aufgabe, wenn die standardmäßige Throttle-Antwort den type "tokens" und den code "rate_limit_exceeded" verwendet, die Token-Zähler des Plugins enthält und Custom weiterhin einen Quota-Fehler simulieren kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

work in progress

Description

When LanguageModelRateLimitingPlugin throttles a request with whenLimitExceeded: "Throttle" (the default), it returns a 429 with this body (DevProxy.Plugins/Behavior/LanguageModelRateLimitingPlugin.cs):

{
  "error": {
    "message": "You exceeded your current quota, please check your plan and billing details.",
    "type": "insufficient_quota",
    "code": "insufficient_quota"
  }
}

That's the body OpenAI uses for a billing or quota error, which means "stop, retrying won't help". OpenAI's docs say: "Retrying billing, spend, or quota errors won't restore API access." (Error codes)

The plugin simulates a token rate limit, which means "wait and retry". So an app that handles OpenAI errors correctly does the wrong thing under Dev Proxy:

  • It stops retrying and shows "out of credits", when it should back off and retry.
  • Its rate limit branch (rate_limit_exceeded) never runs, so the test doesn't cover the code path the plugin is meant to test.

Steps to reproduce

  1. Enable LanguageModelRateLimitingPlugin with a low promptTokenLimit for https://api.openai.com/*.
  2. Send OpenAI requests until the limit is exceeded.
  3. Inspect the 429 body.

Expected behavior

A rate limit error that matches what OpenAI returns when you exceed tokens per minute, for example:

{
  "error": {
    "message": "Rate limit reached for <model> in organization <org> on tokens per min (TPM): Limit <limit>, Used <used>, Requested <requested>. Please try again in <n>s.",
    "type": "tokens",
    "param": null,
    "code": "rate_limit_exceeded"
  }
}

The openai-throttling preset in pnp/proxy-samples already uses this shape.

Actual behavior

The 429 body says insufficient_quota, which clients treat as a billing error.

Proposed fix

Change the default throttle body to rate_limit_exceeded with type: "tokens", and include the token numbers from the plugin's counters in the message. Keep whenLimitExceeded: "Custom" for anyone who wants to simulate a quota error on purpose.

Vorherrschende Sprache
C#
Sterne
841
Forks
90
Ø Merge
2 T. 10 Std.
Gemergte PRs (30 T.)
63

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus dotnet/dev-proxy

Alle Issues in dotnet/dev-proxy

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.