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
39 changes: 23 additions & 16 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ 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"}}',
),
]);
const UNAUTHENTICATED_MESSAGE =
"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential.";
const STATUS_UNAUTHENTICATED_ERROR = Buffer.concat([
Buffer.from([0x12, 0xec, 0x01]),
Buffer.from(
`UNAUTHENTICATED (code 401): ${UNAUTHENTICATED_MESSAGE}\u001a\u0098\u0005HTTP 401 Unauthorized\n\n{"error":{"code":401,"message":"${UNAUTHENTICATED_MESSAGE}","status":"UNAUTHENTICATED"}}`,
),
]);
// 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 @@ -149,8 +157,13 @@ describe("watchAntigravityPromptOutcome", () => {
retryable: false,
}),
);
// A 404 after the turn already reached the model is a transient edge error, not a bad model.
for (const error of [NOT_FOUND_ERROR, STATUS_NOT_FOUND_ERROR]) {
// After the turn reached the model, a 404 is a transient edge error and a 401 an OAuth
// refresh race; before, they are a bad model and a signed-out session.
for (const [error, message, code] of [
[NOT_FOUND_ERROR, "Requested entity was not found.", "NOT_FOUND"],
[STATUS_NOT_FOUND_ERROR, "Requested entity was not found.", "NOT_FOUND"],
[STATUS_UNAUTHENTICATED_ERROR, UNAUTHENTICATED_MESSAGE, "UNAUTHENTICATED"],
] as const) {
assert.deepEqual(
yield* turn([
[USER_INPUT, input],
Expand All @@ -159,24 +172,18 @@ describe("watchAntigravityPromptOutcome", () => {
[ERROR_MESSAGE, error],
]),
{
...reusable({
class: "provider_error",
message: "Requested entity was not found.",
code: "NOT_FOUND",
retryable: true,
}),
...reusable({ class: "provider_error", message, code, retryable: true }),
resumeWith: "continue",
},
);
assert.deepEqual(
yield* turn([
[USER_INPUT, input],
[ERROR_MESSAGE, error],
]),
reusable({ class: "provider_error", message, code, retryable: false }),
);
}
// A 404 before the model answered is an unknown or unentitled model.
assert.equal(
(yield* turn([
[USER_INPUT, input],
[ERROR_MESSAGE, STATUS_NOT_FOUND_ERROR],
]))?.failure.retryable,
false,
);
// A saved thinking block without a valid signature fails every later prompt.
for (const error of [MISSING_SIGNATURE_ERROR, INVALID_SIGNATURE_ERROR]) {
const outcome = yield* turn([
Expand Down
10 changes: 6 additions & 4 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,18 @@ function turnFailure(
}
const [, httpStatus, message, status] = apiError;
const rateLimited = httpStatus === "429" || status === "RESOURCE_EXHAUSTED";
// A 404 before the model answered is an unknown or unentitled model; after, a transient edge error.
const transientNotFound = httpStatus === "404" && step?.reachedModel === true;
// Before the model answered, a 404 is an unknown model and a 401 a signed-out session. After,
// they are a transient edge error and an OAuth token refresh race.
const transientMidTurn =
(httpStatus === "404" || httpStatus === "401") && step?.reachedModel === true;
const failure = makeProviderFailure({
class: rateLimited ? "usage_limit" : "provider_error",
message: message!.trim(),
code: status ?? null,
retryable: rateLimited || transientNotFound || Number(httpStatus) >= 500,
retryable: rateLimited || transientMidTurn || Number(httpStatus) >= 500,
resetAt: resetAtFrom(text, now) ?? null,
});
return transientNotFound
return transientMidTurn
? { failure, threadDisposition: "reusable", resumeWith: "continue" }
: reusable(failure);
}
Expand Down
Loading