PEP-268: мок лимита — сброс через 2 часа вместо фиксированных 5pm
С PEP-300 баннер с прошедшим временем сброса не считается лимитом, и тест «usage limit banner» падал каждый день 17:00–21:00 (и на main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ccf12b3a6
commit
be58172bca
@ -434,15 +434,17 @@ async function run(action: Action): Promise<boolean> {
|
||||
} else if ("limit" in action) {
|
||||
const spec = typeof action.limit === "object" ? action.limit : {};
|
||||
if (spec.credential && !(credential() ?? "").includes(spec.credential)) return true;
|
||||
const at = spec.resetInSec != null ? new Date(Date.now() + spec.resetInSec * 1000).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" }) : null;
|
||||
const when = spec.reset === "unknown" ? "" : at ? ` resets at ${at}` : " resets 5pm";
|
||||
// No reset given — two hours ahead, not a fixed «5pm»: a fixed clock time reads as an already
|
||||
// passed reset in the hours after it (PEP-300) and the limit tests failed every day 17:00–21:00.
|
||||
const at = new Date(Date.now() + (spec.resetInSec ?? 2 * 3600) * 1000).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
|
||||
const when = spec.reset === "unknown" ? "" : ` resets at ${at}`;
|
||||
if (provider === "claude") {
|
||||
out(`⎿ Claude usage limit reached.${when ? ` Your limit${when.replace(" resets", " will reset")}.` : ""}\n`);
|
||||
// Per the hooks docs, last_assistant_message of StopFailure is the API error text, not
|
||||
// Claude's output; error_details is optional and its live wording is unverified (PEP-3).
|
||||
await fireHook("StopFailure", { error: "rate_limit", error_details: `Usage limit reached${when ? `,${when}` : ""}`, last_assistant_message: `API Error: Claude usage limit reached.${when ? ` Your limit${when.replace(" resets", " will reset")}.` : ""}` }, "rate_limit");
|
||||
} else {
|
||||
out(`■ You’ve hit your usage limit.${spec.reset === "unknown" ? "" : ` Try again at ${at ?? "5:00 PM"}.`}\n`);
|
||||
out(`■ You’ve hit your usage limit.${spec.reset === "unknown" ? "" : ` Try again at ${at}.`}\n`);
|
||||
}
|
||||
log("limit");
|
||||
return false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user