Arm the shared cooldown for rate limits tunneled through HTTP 200
Azure is the only zero-data-retention route for the gpt-5.6 family, so its capacity 429s arrive frequently and OpenRouter forwards them inside an HTTP 200 envelope. Those bypassed the rate controller entirely: a paced run kept sending a request every three seconds into a throttled endpoint, failing row by row. An in-envelope 429 now records the same escalating cooldown as a transport 429, so later acquisitions fail fast until the deadline passes.
This commit is contained in:
@@ -365,6 +365,12 @@ func (c *Client) complete(ctx context.Context, gate *ratelimit.Controller, r com
|
||||
Code int `json:"code"`
|
||||
}
|
||||
_ = json.Unmarshal(envelope.Error, &detail)
|
||||
if detail.Code == http.StatusTooManyRequests {
|
||||
// An upstream rate limit tunneled through HTTP 200 must arm the
|
||||
// same cooldown as a transport 429: later Acquire calls fail fast
|
||||
// instead of pacing more requests into a throttled endpoint.
|
||||
return "", gate.ReportLimit()
|
||||
}
|
||||
if detail.Code != 0 {
|
||||
return "", fmt.Errorf("AI provider reported an error (code %d)", detail.Code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user