Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(claude): keep limits when the usage fetch fails #10597

ClosedMhmdhammoud(GitHub profile, opens in a new tab)wants to merge 10 commits intomain fromrefs/pull/10597/headopened View on GitHub

Showing 2 changed files with 16 additions and 1 deletion.

x
0 of 2 viewed, 2 left
9 additions and 0 deletionsapps/server/src/provider/Layers/claudeUsageLimits.test.tsModified
View file
@@ -95,6 +95,15 @@
).toEqual({ checkedAt, windows: [], unavailable: { reason: "unsupported" } });
});
​
+ it("reports a failed usage fetch as probeFailed so clients keep the last good windows", () => {
+ expect(
+ claudeUsageResponseToLimits({
+ checkedAt,
+ response: { rate_limits_available: true, rate_limits: null },
+ }).limits,
+ ).toEqual({ checkedAt, windows: [], unavailable: { reason: "probeFailed" } });
+ });
+​
it("skips a window the endpoint reports without a utilization", () => {
expect(
claudeUsageResponseToLimits({
7 additions and 1 deletionapps/server/src/provider/Layers/claudeUsageLimits.tsModified
View file
@@ -159,9 +159,15 @@
readonly checkedAt: string;
}): { readonly limits: ServerProviderUsageLimits; readonly names: ClaudeScopedLimitNames } {
const { response, checkedAt } = input;
+ // The CLI keeps `rate_limits_available` true and nulls `rate_limits` when
+ // the usage fetch itself failed, e.g. the endpoint answered 429. Only an
+ // explicit false means the account can never report windows.
if (!response.rate_limits_available || !response.rate_limits) {
return {
- limits: makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" }),