mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba292200a6
commit
53b9d7440d
8 files changed
+58
-1
No files matched your search
@@ -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";
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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<string>([
|
||||
"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
|
||||
|
||||
@@ -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<typeof antigravity>) =>
|
||||
({ ...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" } };
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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<string>([
|
||||
|
||||
const NON_RETRYABLE_CONTINUATION_ERROR_CODES = new Set<string>([
|
||||
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",
|
||||
|
||||
Reference in new issue
Block a user