From be58172bca1bdf4315c2f994c7f3804be9347f07 Mon Sep 17 00:00:00 2001 From: peppa-bot Date: Thu, 26 Nov 2026 17:27:16 +0000 Subject: [PATCH] =?UTF-8?q?PEP-268:=20=D0=BC=D0=BE=D0=BA=20=D0=BB=D0=B8?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D0=B0=20=E2=80=94=20=D1=81=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D1=81=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=202=20=D1=87=D0=B0?= =?UTF-8?q?=D1=81=D0=B0=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=205pm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit С PEP-300 баннер с прошедшим временем сброса не считается лимитом, и тест «usage limit banner» падал каждый день 17:00–21:00 (и на main). Co-Authored-By: Claude Opus 5.5 --- packages/testkit/src/mock-agent.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/testkit/src/mock-agent.ts b/packages/testkit/src/mock-agent.ts index 6ca1a6f2..b2a0240f 100644 --- a/packages/testkit/src/mock-agent.ts +++ b/packages/testkit/src/mock-agent.ts @@ -434,15 +434,17 @@ async function run(action: Action): Promise { } 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;