diff --git a/apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts b/apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts index 962da73bfc2bd..b1c15b1396a7b 100644 --- a/apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts +++ b/apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts @@ -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.", @@ -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( diff --git a/apps/server/src/provider/acp/AntigravityTurnOutcome.ts b/apps/server/src/provider/acp/AntigravityTurnOutcome.ts index 35ed2f347df1d..59057794722d3 100644 --- a/apps/server/src/provider/acp/AntigravityTurnOutcome.ts +++ b/apps/server/src/provider/acp/AntigravityTurnOutcome.ts @@ -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 = { ns: 1e-6, @@ -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)) {