Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ const STATUS_NOT_FOUND_ERROR = Buffer.concat([
'NOT_FOUND (code 404): Requested entity was not found.\u001a\u0080\u0001HTTP 404 Not Found\n\n{"error":{"code":404,"message":"Requested entity was not found.","status":"NOT_FOUND"}}',
),
]);
// Antigravity 1.5 states the quota reset only as a Go duration in its message.
const STATUS_QUOTA_ERROR = Buffer.concat([
Buffer.from([0x12, 0x6e]),
Buffer.from(
"RESOURCE_EXHAUSTED (code 429): Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 4m42s.",
),
]);
// The model's reply quoting the agent's quota notice is an ordinary planner response.
const QUOTED_NOTICE = Buffer.from(
"Usage Limit Reached\n\nYou have reached your current quota for this period. Your limit will reset in 1 hour.",
Expand Down Expand Up @@ -122,6 +129,13 @@ describe("watchAntigravityPromptOutcome", () => {
resetAt: "1970-01-01T01:00:00.000Z",
}),
);
assert.deepInclude(
(yield* turn([
[USER_INPUT, input],
[ERROR_MESSAGE, STATUS_QUOTA_ERROR],
]))?.failure,
{ class: "usage_limit", resetAt: "1970-01-01T00:04:42.000Z" },
);
// The earlier error step is outside this turn.
assert.isUndefined(
yield* turn(
Expand Down
5 changes: 4 additions & 1 deletion apps/server/src/provider/acp/AntigravityTurnOutcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const RESET_TIMESTAMP = /\bquotaResetTimeStamp:([^\s\]]+)/;
const RESET_DELAY = /\bquotaResetDelay:((?:\d+(?:\.\d+)?(?:ns|us|µs|μs|ms|h|m|s))+)(?=[\s\]])/;
// google.rpc.RetryInfo, which plain rate limits carry instead of a quota reset.
const RETRY_DELAY = /\bretryDelay:((?:\d+(?:\.\d+)?(?:ns|us|µs|μs|ms|h|m|s))+)(?=[\s\]])/;
// Antigravity 1.5 may state the reset only in the message: "... Resets in 4m42s.".
const RESETS_IN = /\bResets in ((?:\d+(?:\.\d+)?(?:ns|us|µs|μs|ms|h|m|s))+)(?!\w|\.\d)/;
const GO_DURATION_PART = /(\d+(?:\.\d+)?)(ns|us|µs|μs|ms|h|m|s)/g;
const GO_DURATION_UNIT_MS: Record<string, number> = {
ns: 1e-6,
Expand Down Expand Up @@ -113,7 +115,8 @@ function resetAtFrom(text: string, now: DateTime.Utc | undefined): string | unde
// makeProviderFailure drops a timestamp that does not parse, so fall back to the delay.
const timestamp = RESET_TIMESTAMP.exec(text)?.[1];
if (timestamp !== undefined && Option.isSome(DateTime.make(timestamp))) return timestamp;
const delay = RESET_DELAY.exec(text)?.[1] ?? RETRY_DELAY.exec(text)?.[1];
const delay =
RESET_DELAY.exec(text)?.[1] ?? RETRY_DELAY.exec(text)?.[1] ?? RESETS_IN.exec(text)?.[1];
if (delay === undefined || now === undefined) return undefined;
let delayMs = 0;
for (const [, amount, unit] of delay.matchAll(GO_DURATION_PART)) {
Expand Down
Loading