From 53b9d7440d719f28b6058e805fd8cbd3d0b896b5 Mon Sep 17 00:00:00 2001 From: Dotta Date: Tue, 24 Nov 2026 12:43:01 -0600 Subject: [PATCH] fix(antigravity): a refused /swarm waits for the user instead of retrying Live proof found a refused swarm (after the automatic attempt cap) failing as adapter_failed, so transient retry and continuation recovery started a new run every minute or two, each refusing again. A swarm refusal now settles with its own non-retryable code, antigravity_swarm_unavailable, which bounded retry, continuation recovery and the issue-comment policy all leave for the user (send /swarm again, or Retry). Co-Authored-By: Claude Opus 5.5 --- .../src/services/antigravity-swarm-refusal.ts | 7 ++++++ server/src/services/antigravity-swarm.ts | 3 ++- .../services/heartbeat/run-completion.test.ts | 11 ++++++++ .../src/services/heartbeat/run-completion.ts | 3 +++ .../src/services/heartbeat/run-lifecycle.ts | 3 +++ .../native-session-resume.test.ts | 25 +++++++++++++++++++ .../provider-failure-classification.test.ts | 4 +++ server/src/services/recovery/service.ts | 3 +++ 8 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 server/src/services/antigravity-swarm-refusal.ts diff --git a/server/src/services/antigravity-swarm-refusal.ts b/server/src/services/antigravity-swarm-refusal.ts new file mode 100644 index 00000000000..f64018ef0c9 --- /dev/null +++ b/server/src/services/antigravity-swarm-refusal.ts @@ -0,0 +1,7 @@ +/** + * The failure code of a requested /swarm that cannot run (services/antigravity-swarm.ts). + * Kept in this leaf module so run settlement and recovery can name it without + * importing the swarm service. A refusal waits for the user: nothing retries + * it automatically, because every automatic attempt would refuse the same way. + */ +export const ANTIGRAVITY_SWARM_UNAVAILABLE = "antigravity_swarm_unavailable"; diff --git a/server/src/services/antigravity-swarm.ts b/server/src/services/antigravity-swarm.ts index 77f95d36436..e55a61400b6 100644 --- a/server/src/services/antigravity-swarm.ts +++ b/server/src/services/antigravity-swarm.ts @@ -20,7 +20,8 @@ import { PaperclipRunnerProviderProfileError } from "./native-runtime/provider-p * never run as an ordinary request. */ export const ANTIGRAVITY_SWARM_COMMAND = "swarm" as const; -export const ANTIGRAVITY_SWARM_UNAVAILABLE = "antigravity_swarm_unavailable"; +export { ANTIGRAVITY_SWARM_UNAVAILABLE } from "./antigravity-swarm-refusal.js"; +import { ANTIGRAVITY_SWARM_UNAVAILABLE } from "./antigravity-swarm-refusal.js"; /** Automatic wakes (recovery, sweeps) attempt one swarm request at most this often; the user can always ask again. */ export const ANTIGRAVITY_SWARM_AUTOMATIC_ATTEMPTS = 3; diff --git a/server/src/services/heartbeat/run-completion.test.ts b/server/src/services/heartbeat/run-completion.test.ts index 88b1b95dbe0..a6e7a8c324e 100644 --- a/server/src/services/heartbeat/run-completion.test.ts +++ b/server/src/services/heartbeat/run-completion.test.ts @@ -1,3 +1,4 @@ +import { PaperclipRunnerProviderProfileError } from "../native-runtime/provider-profile.js"; import { promises as fs } from "node:fs"; import { createDurableRunLogStore } from "../run-log-store.js"; import { createServer } from "node:http"; @@ -1131,6 +1132,16 @@ describe.skipIf(!support.supported && !process.env.PAPERCLIP_TEST_DATABASE_URL)( expect(f.deps.finalizeIssueCommentPolicy).not.toHaveBeenCalled(); }); + it("settles a refused /swarm as its own failure that nothing retries automatically", async () => { + const f = await fixture(); + const refusal = new PaperclipRunnerProviderProfileError("antigravity_swarm_unavailable", + "The swarm did not finish after three attempts, so Paperclip stopped retrying it. Send /swarm again to start a new one."); + await f.completion.failRun(f.failure(refusal)); + expect(await read(f.run.id)).toMatchObject({ status: "failed", errorCode: "antigravity_swarm_unavailable", error: refusal.message }); + expect(f.deps.scheduleBoundedRetryForRun).not.toHaveBeenCalled(); + expect(f.deps.enqueueWakeup).not.toHaveBeenCalled(); + }); + it("names a full sandbox disk that the sandbox provider reported during setup", async () => { const f = await fixture(); const refusal = new JsonRpcCallError({ code: PLUGIN_RPC_ERROR_CODES.WORKER_ERROR, diff --git a/server/src/services/heartbeat/run-completion.ts b/server/src/services/heartbeat/run-completion.ts index 62e5a0ee0d8..1c557b95b71 100644 --- a/server/src/services/heartbeat/run-completion.ts +++ b/server/src/services/heartbeat/run-completion.ts @@ -15,6 +15,8 @@ import { settledResponsePublicationSql } from "../native-runtime/native-response import { notifyChatRunMilestones } from "../chat-run-milestone-notifications.js"; import { measureRunPhase } from "../execution-preparation-timing.js"; import { PROJECT_ACCESS_DENIED, ProjectAccessDeniedError } from "../project-access-denial.js"; +import { ANTIGRAVITY_SWARM_UNAVAILABLE } from "../antigravity-swarm-refusal.js"; +import { PaperclipRunnerProviderProfileError } from "../native-runtime/provider-profile.js"; import { pendingCaseHandoffForRun } from "./case-handoff-lifecycle.js"; import { NON_RETRYABLE_PREFLIGHT_FAILURE_CODES, isHeartbeatRunTerminalStatus } from "./run-lifecycle.js"; import { ChatControlRecoveryUnresolvedError } from "./queue.js"; @@ -189,6 +191,7 @@ export interface FailHeartbeatRunSetupInput { function nonRetryablePreflightFailureCode(error: unknown): string | null { if (error instanceof ProjectAccessDeniedError) return PROJECT_ACCESS_DENIED; + if (error instanceof PaperclipRunnerProviderProfileError && error.code === ANTIGRAVITY_SWARM_UNAVAILABLE) return ANTIGRAVITY_SWARM_UNAVAILABLE; if (error instanceof ChatControlRecoveryUnresolvedError) return CHAT_CONTROL_RECOVERY_UNRESOLVED_CODE; if ( diff --git a/server/src/services/heartbeat/run-lifecycle.ts b/server/src/services/heartbeat/run-lifecycle.ts index 8e444d2c935..b7bade9503b 100644 --- a/server/src/services/heartbeat/run-lifecycle.ts +++ b/server/src/services/heartbeat/run-lifecycle.ts @@ -1,3 +1,4 @@ +import { ANTIGRAVITY_SWARM_UNAVAILABLE } from "../antigravity-swarm-refusal.js"; import { notifyTerminalWorkspaceWork } from "../terminal-workspace-work.js"; import { settleReattachRun } from "./run-admission.js"; import { readNativeStartupCleanup } from "../native-runtime/native-startup-cleanup.js"; @@ -280,6 +281,8 @@ export const NON_RETRYABLE_PREFLIGHT_FAILURE_CODES = new Set([ "low_trust_runtime_services_denied", "chat_failed_run_retry_not_authorized", CHAT_CONTROL_RECOVERY_UNRESOLVED_CODE, + // A requested /swarm that cannot run waits for the user (send /swarm again or Retry). + ANTIGRAVITY_SWARM_UNAVAILABLE, ]); // Error codes that mark a pre-dispatch setup failure. The adapter process never diff --git a/server/src/services/native-runtime/native-session-resume.test.ts b/server/src/services/native-runtime/native-session-resume.test.ts index aeeddaaa185..7012a3b191d 100644 --- a/server/src/services/native-runtime/native-session-resume.test.ts +++ b/server/src/services/native-runtime/native-session-resume.test.ts @@ -406,6 +406,31 @@ describe("a Google Antigravity session saved by the pending candidate", () => { }); }); +describe("a Google Antigravity swarm and the task's ordinary session", () => { + // A swarm runs on the Antigravity CLI in a fresh session every time; the + // ordinary route cannot reopen the CLI's conversation, nor the CLI the + // ordinary one. Neither direction resumes: the next run starts fresh in the same workspace. + const antigravity = (runId: string, swarmRequest?: string) => buildNativeExecutionInput({ + companyId, runId, + issue: { id: issueId, identifier: "DOT-2", title: "Test", description: null, workMode: "standard" }, + taskPrompt: "Only the current turn", agentId, + workspace: { id: runId, cwd: "/workspace", repoUrl: null, repoRef: null, branchName: null }, + normalizedSessionId, provider: "acpx", acpxAgent: "antigravity", model: "gemini-3.8-flash-low", + acpxPermissionMode: "approve-all", completionContract: execution(runId).completionContract, + runtimeContext: nativeRuntimeContextFixture(), + ...(swarmRequest === undefined ? {} : { antigravitySwarmRequest: swarmRequest }), + }); + const savedBy = (saved: ReturnType) => + ({ ...previousRun(), runnerProfileJson: { ...previousRun().runnerProfileJson, nativeExecutionInput: saved } }); + + it("starts a swarm in a fresh session after an ordinary run, and an ordinary run fresh after a swarm", () => { + expect(rebindNativeSessionCheckpoint({ previousRun: savedBy(antigravity(previousRunId)), currentExecution: antigravity(currentRunId) })).not.toBeNull(); + expect(rebindNativeSessionCheckpoint({ previousRun: savedBy(antigravity(previousRunId)), currentExecution: antigravity(currentRunId, "write a.txt") })).toBeNull(); + expect(rebindNativeSessionCheckpoint({ previousRun: savedBy(antigravity(previousRunId, "write a.txt")), currentExecution: antigravity(currentRunId) })).toBeNull(); + expect(rebindNativeSessionCheckpoint({ previousRun: savedBy(antigravity(previousRunId, "write a.txt")), currentExecution: antigravity(currentRunId, "write b.txt") })).toBeNull(); + }); +}); + describe("a source whose provider state was not saved after its result was accepted", () => { const unsaved = { [NATIVE_PROVIDER_STATE_UNSAVED_KEY]: { code: NATIVE_PROVIDER_STATE_INCOMPATIBLE, reason: "harness_backup_not_saved", recordedAt: "2026-11-11T00:00:00.000Z" } }; diff --git a/server/src/services/recovery/provider-failure-classification.test.ts b/server/src/services/recovery/provider-failure-classification.test.ts index deeca9bdd2d..e7f509a2687 100644 --- a/server/src/services/recovery/provider-failure-classification.test.ts +++ b/server/src/services/recovery/provider-failure-classification.test.ts @@ -23,6 +23,10 @@ describe("classifyAdapterFailureForRecovery", () => { expect(classifyContinuationFailure({ errorCode: "agent_interaction_delivery_denied", resultJson: null } as never)) .toMatchObject({ kind: "non_retryable", maxAttempts: 0 }); }); + it("does not automatically replay a refused /swarm (the user sends /swarm again or presses Retry)", () => { + expect(classifyContinuationFailure({ errorCode: "antigravity_swarm_unavailable", resultJson: null } as never)) + .toMatchObject({ kind: "non_retryable", maxAttempts: 0 }); + }); it("does not automatically replay a project access denial", () => { expect(classifyContinuationFailure({ errorCode: "project_access_denied", resultJson: null } as never)) .toMatchObject({ kind: "non_retryable", maxAttempts: 0 }); diff --git a/server/src/services/recovery/service.ts b/server/src/services/recovery/service.ts index 3a862ecfd62..036d4b5f7f9 100644 --- a/server/src/services/recovery/service.ts +++ b/server/src/services/recovery/service.ts @@ -1,4 +1,5 @@ import { wakeWaitersOfStalledIssues, type BlockerStallWakeup } from "./blocker-stall-wakeups.js"; +import { ANTIGRAVITY_SWARM_UNAVAILABLE } from "../antigravity-swarm-refusal.js"; import { INTERACTION_DELIVERY_DENIED, isInteractionDeliveryDeniedRun } from "../agent-interaction-delivery.js"; import { notifyScheduledRetryDispatch } from "../run-dispatch-notifications.js"; import { OWNER_UNPROVABLE_CAUSE } from "./owner-gone-attestation.js"; @@ -617,6 +618,8 @@ const TRANSIENT_INFRA_CONTINUATION_ERROR_CODES = new Set([ const NON_RETRYABLE_CONTINUATION_ERROR_CODES = new Set([ INTERACTION_DELIVERY_DENIED, + // A refused /swarm waits for the user; every automatic attempt would refuse again. + ANTIGRAVITY_SWARM_UNAVAILABLE, "project_access_denied", "native_provider_model_rejected", "provider_tool_definition_invalid",