mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-05 13:52:57 +00:00
fix(auth): keep timeout expiry per profile
This commit is contained in:
@@ -95,6 +95,26 @@ describe("getSoonestCooldownExpiry", () => {
|
||||
).toBe(now + 30_000);
|
||||
});
|
||||
|
||||
it("uses the earliest matching timeout cooldown for the requested model", () => {
|
||||
const now = 1_700_000_000_000;
|
||||
const store = makeStore({
|
||||
"openai:p1": {
|
||||
cooldownUntil: now + 10_000,
|
||||
cooldownReason: "timeout",
|
||||
cooldownModel: "gpt-5.4",
|
||||
},
|
||||
"openai:p2": {
|
||||
cooldownUntil: now + 30_000,
|
||||
cooldownReason: "timeout",
|
||||
cooldownModel: "gpt-5.4",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
getSoonestCooldownExpiry(store, ["openai:p1", "openai:p2"], { now, forModel: "gpt-5.4" }),
|
||||
).toBe(now + 10_000);
|
||||
});
|
||||
|
||||
it("still counts profile-wide disables for other models", () => {
|
||||
const now = 1_700_000_000_000;
|
||||
const store = makeStore({
|
||||
|
||||
@@ -104,7 +104,7 @@ export function getSoonestCooldownExpiry(
|
||||
}
|
||||
const matchingModelScopedCooldown =
|
||||
options?.forModel &&
|
||||
isModelScopedCooldownReason(stats.cooldownReason) &&
|
||||
stats.cooldownReason === "rate_limit" &&
|
||||
stats.cooldownModel === options.forModel &&
|
||||
!isActiveUnusableWindow(stats.blockedUntil, ts) &&
|
||||
!isActiveUnusableWindow(stats.disabledUntil, ts);
|
||||
|
||||
Reference in New Issue
Block a user