Skip to content
Open
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
30 changes: 30 additions & 0 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ const MISSING_SIGNATURE_ERROR = errorPayload(
const INVALID_SIGNATURE_ERROR = errorPayload(
'Error 400, Message: {"type":"error","error":{"type":"invalid_request_error","message":"messages.3.content.0: Invalid `signature` in `thinking` block"}}, Status: INVALID_ARGUMENT, Details: []',
);
// Context summarization replays a stored failed checkpoint step on every later prompt.
const FAILED_CHECKPOINT_ERROR = errorPayload(
'context summarization: checkpoint step 841 failed: error executing cascade step: CORTEX_STEP_TYPE_CHECKPOINT: doRequest: error sending request: auth: "invalid_grant" "reauth related error (invalid_rapt)"',
);
const FAILED_CHECKPOINT_QUOTA_ERROR = errorPayload(
"context summarization: checkpoint step 841 failed: Error 429, Message: Quota exhausted for test model., Status: RESOURCE_EXHAUSTED, Details: [map[@type:type.googleapis.com/google.rpc.ErrorInfo domain:googleapis.com metadata:map[quotaResetDelay:3600s] reason:QUOTA_EXHAUSTED]]",
);
// 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 @@ -148,6 +155,29 @@ describe("watchAntigravityPromptOutcome", () => {
assert.equal(outcome?.failure.code, "INVALID_THINKING_SIGNATURE");
assert.equal(outcome?.threadDisposition, "broken");
}
const checkpoint = yield* turn([
[USER_INPUT, input],
[ERROR_MESSAGE, FAILED_CHECKPOINT_ERROR],
]);
assert.equal(checkpoint?.failure.code, "CHECKPOINT_FAILED");
assert.equal(checkpoint?.threadDisposition, "broken");
// A checkpoint that failed on quota keeps the reset time usage-limit recovery waits for.
assert.deepEqual(
yield* turn([
[USER_INPUT, input],
[ERROR_MESSAGE, FAILED_CHECKPOINT_QUOTA_ERROR],
]),
{
failure: {
class: "usage_limit",
message: "You have reached your Antigravity quota for this period.",
code: "RESOURCE_EXHAUSTED",
retryable: true,
resetAt: "1970-01-01T01:00:00.000Z",
},
threadDisposition: "broken",
},
);
// A completed tool keeps its usage, and the turn still fails.
assert.equal(
(yield* turn(
Expand Down
29 changes: 24 additions & 5 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const QUOTA_EXHAUSTED = /\breason:QUOTA_EXHAUSTED\b/;
// history, so every later prompt to that session fails the same way.
const INVALID_THINKING_SIGNATURE =
/\bmessages\.\d+\.content\.\d+(?:\.thinking\.signature: Field required|: Invalid `signature` in `thinking` block)/;
// The runtime stores a failed context-summarization step and replays it on every later
// prompt to that session, whatever first made it fail.
const FAILED_CHECKPOINT = /\bcontext summarization: checkpoint step \d+ failed\b/;
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.
Expand Down Expand Up @@ -124,10 +127,26 @@ function turnFailure(
if (errorText === undefined && stopReason !== "refusal") return undefined;
const text = errorText ?? "";
const apiError = API_ERROR.exec(text);
const reusable = (failure: OrchestrationV2ProviderFailure) =>
({ failure, threadDisposition: "reusable" }) as const;
const failedCheckpoint = FAILED_CHECKPOINT.test(text);
const settle = (failure: OrchestrationV2ProviderFailure) =>
failedCheckpoint
? {
// A quota failure keeps its reset time so usage-limit recovery can resume the thread.
failure:
failure.class === "usage_limit"
? failure
: makeProviderFailure({
class: "provider_error",
message:
"Antigravity could not summarize this conversation, so its saved session can no longer continue. The next message starts a fresh Antigravity session with this thread's context.",
code: "CHECKPOINT_FAILED",
retryable: true,
}),
threadDisposition: "broken" as const,
}
: ({ failure, threadDisposition: "reusable" } as const);
if (stopReason === "refusal" || QUOTA_EXHAUSTED.test(text)) {
return reusable(
return settle(
makeProviderFailure({
class: "usage_limit",
message: "You have reached your Antigravity quota for this period.",
Expand All @@ -150,7 +169,7 @@ function turnFailure(
};
}
if (apiError === null) {
return reusable(
return settle(
makeProviderFailure({
class: "provider_error",
message: "Antigravity stopped this turn because of an error.",
Expand All @@ -159,7 +178,7 @@ function turnFailure(
}
const [, httpStatus, message, status] = apiError;
const rateLimited = httpStatus === "429" || status === "RESOURCE_EXHAUSTED";
return reusable(
return settle(
makeProviderFailure({
class: rateLimited ? "usage_limit" : "provider_error",
message: message!.trim(),
Expand Down
Loading