fix(antigravity): a refused /swarm shows one plain sentence and no dead-end Retry

The live Neon refusal showed "antigravity: Provider error", the raw provider
code, a Retry that meets the same refusal, and the Runner's command JSON as the
agent's error reason. The run error is now the refusal's own sentence (raw text
stays in the recovery history), a requires-action swarm refusal offers no
Retry, the provider banner names Google Antigravity and no longer prints
provider codes or HTTP statuses, and the chat marker says what happened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 committed 2026-11-24 16:05:21 -06:00
1 parent 3f880a8205
commit a2a40c1ac2
8 files changed
+103 -5

No files matched your search

@@ -479,6 +479,7 @@ import {
retainedNativeCleanupJournalMatches,
nativeProviderUsageLimitFromEvent,
nativeSessionFailureSourceCode,
nativeStartupFailureMessage,
NATIVE_PROVIDER_SESSION_CLOSED,
NATIVE_PROVIDER_STARTUP_REJECTED,
nativeRemoteStartupRejectionCode,
@@ -16128,6 +16129,18 @@ describe("native session bounded recovery", () => {
expect(nativeSessionFailureSourceCode(rejected("unclassified"))).toBe("provider_session_open_rejected");
});
it("gives a refused /swarm one plain sentence as its run error, never the Runner's command JSON", () => {
// The live Neon refusal (2026-11-24): the PRP failure text with the typed provider failure inside.
const plain = "Swarm is not available with Gemini 4 Neon (Low) yet, so nothing was changed: choose another model for this agent, such as Gemini 4 Argon, and send /swarm again.";
const raw = `PRP command session.open failed: {"commandId":"command_prp_00000002","commandType":"session.open","controllerSeq":2,"result":{"code":"command_execution_failed","message":"failed to start ACPX provider: ACPX sidecar command session.open was rejected (retryable=false, classification=antigravity_swarm_unavailable)","providerFailure":{"schema":"paperclip.provider-failure.v1","provider":"antigravity","phase":"startup","category":"model_unavailable","message":${JSON.stringify(plain)},"retryability":"requires_action"},"sidecarRejection":{"command":"session.open","code":"ANTIGRAVITY_SWARM_UNAVAILABLE","message":"The Antigravity CLI offered 13 models and not gemini-4-neon-low: gemini-4-argon-medium"}},"status":"failed"}`;
const error = new Error(raw);
expect(nativeSessionFailureSourceCode(error)).toBe("antigravity_swarm_unavailable");
expect(nativeStartupFailureMessage("antigravity_swarm_unavailable", raw, { message: plain })).toBe(plain);
// Other failures keep their text; a swarm refusal without a typed cause keeps the raw text rather than nothing.
expect(nativeStartupFailureMessage("provider_session_open_rejected", raw, { message: plain })).toBe(raw);
expect(nativeStartupFailureMessage("antigravity_swarm_unavailable", raw, null)).toBe(raw);
});
it("rests a run whose Runner refused its commands as out of sequence with a precise code and a Retry", () => {
const refused = new Error(`PRP command session.open rejected: {"commandId":"c","controllerSeq":11,"commandType":"session.open","status":"rejected","result":{"code":"controller_sequence_mismatch","message":"controller sequence must be contiguous: expected 13, received 11","expectedControllerSeq":13,"receivedControllerSeq":11}}`);
expect(nativeSessionFailureSourceCode(refused)).toBe(NATIVE_CONTROLLER_JOURNAL_BEHIND_RUNNER);
@@ -9026,6 +9026,21 @@ function armWarmNativeSessionIdleTimer(
export { nativeProviderUsageLimitFromEvent };
/**
* The run's error text. A refused /swarm carries one plain sentence for the
* person who asked (its provider failure), so the board and the agent's error
* reason never show the Runner's command JSON; the raw text stays in the
* recovery history's stderr tail for diagnostics.
*/
export function nativeStartupFailureMessage(
sourceFailureCode: string,
originalMessage: string,
providerFailure: { message: string } | null,
): string {
if (sourceFailureCode === ANTIGRAVITY_SWARM_UNAVAILABLE && providerFailure?.message.trim()) return providerFailure.message.trim();
return runFailureMessage({ errorCode: sourceFailureCode, error: originalMessage })!;
}
export function nativeSessionFailureDisposition(
attempt: number,
now = new Date(),
@@ -13520,7 +13535,7 @@ async function executePaperclipNativeSessionAttempt(
const originalMessage = redactOutputText(
error instanceof Error ? error.message : String(error),
).slice(0, 2_000);
const message = runFailureMessage({ errorCode: sourceFailureCode, error: originalMessage })!;
const message = nativeStartupFailureMessage(sourceFailureCode, originalMessage, providerFailure);
const sanitizedStderrTail = originalMessage.slice(-4_096);
const remoteRunnerRecovery = readRemoteRunnerRecoveryError(error);
// Set inside the transaction only when the write below genuinely
@@ -367,6 +367,19 @@ it("preserves a provider explanation on a failed task without changing retry aut
.not.toHaveProperty("providerFailure");
});
it("shows a refused /swarm's plain reason without a Retry that would meet the same refusal", () => {
const providerFailure = { schema: "paperclip.provider-failure.v1", provider: "antigravity", phase: "startup",
category: "model_unavailable", retryability: "requires_action",
message: "Swarm is not available with Gemini 4 Neon (Low) yet, so nothing was changed: choose another model for this agent, such as Gemini 4 Argon, and send /swarm again." };
const refused = { ...run, errorCode: "antigravity_swarm_unavailable", error: providerFailure.message, resultJson: { providerFailure } };
expect(projectTaskInterruption(issue, { run: refused, agent, paused: false, approval: false }))
.toMatchObject({ state: "failed", canRetry: false, providerFailure });
// A swarm verification failure that may not repeat keeps its Retry.
const mismatch = { ...providerFailure, category: "unknown", retryability: "unknown", message: "Swarm stopped before it started: the provider did not confirm auto mode. Nothing was changed." };
expect(projectTaskInterruption(issue, { run: { ...refused, resultJson: { providerFailure: mismatch } }, agent, paused: false, approval: false }))
.toMatchObject({ state: "failed", canRetry: true });
});
it("asks for billing action for an exhausted provider quota without inventing a retry time", () => {
const failed = { ...run, errorCode: "native_provider_usage_limit", resultJson: { providerFailure: {
schema: "paperclip.provider-failure.v1", provider: "openai", phase: "turn",
@@ -1,4 +1,5 @@
import { ENVIRONMENT_PROVIDER_WAIT_KEY, ENVIRONMENT_PROVIDER_WAIT_RETRY_REASON, environmentProviderWaitMessage } from "./environment-provider-wait.js";
import { ANTIGRAVITY_SWARM_UNAVAILABLE } from "./antigravity-swarm-refusal.js";
import { STORAGE_UNAVAILABLE_WAIT_RETRY_REASON } from "../storage/storage-unavailable.js";
import { AGENT_DIRECTORY_WAIT_RETRY_REASON, INTERRUPTED_PREPARATION_RETRY_REASON } from "./execution-recovery-attempt.js";
import { boundSetupCommandFailure, readSetupCommandFailure } from "./workspace-setup-command-failure.js";
@@ -424,6 +425,12 @@ function projectTaskInterruptionState(issue: ProjectionIssue, input: ProjectionS
}
if (run.status === "failed" && isProviderQuotaActionRequired(run, new Date(now)))
return { ...base, responsibility: "user", state: "waiting_for_user", userAction: "provider_billing", canRetry: true };
// A /swarm the swarm route refused for a reason the person must change (the
// model, a planning run, extra tool servers): Retry would meet the same
// refusal, so the plain message says what to do and no Retry is offered.
if (run.status === "failed" && run.errorCode === ANTIGRAVITY_SWARM_UNAVAILABLE
&& providerFailure?.provider === "antigravity" && providerFailure.retryability === "requires_action")
return { ...base, state: "failed", canRetry: false };
return { ...base, state: "failed", canRetry: true, ...(projectAccess ? { projectAccess } : {}) };
}
@@ -0,0 +1,23 @@
import { renderToStaticMarkup } from "react-dom/server";
import { expect, it } from "vitest";
import type { ProviderFailure } from "@paperclipai/shared";
import { ProviderFailureNotice } from "./ProviderFailureNotice";
const render = (failure: ProviderFailure) => renderToStaticMarkup(<ProviderFailureNotice failure={failure} />);
it("names the provider in plain words and shows no raw provider code or HTTP status", () => {
// The live swarm quota refusal (2026-11-24) rendered as "antigravity: ... · HTTP 429 · RESOURCE_EXHAUSTED".
const html = render({ schema: "paperclip.provider-failure.v1", provider: "antigravity", phase: "turn", category: "rate_limit",
message: "Google refused the swarm: this account is out of quota for now. Try again later.", httpStatus: 429,
providerCode: "RESOURCE_EXHAUSTED", retryability: "unknown" });
expect(html).toContain("Google Antigravity: Rate limit reached");
expect(html).toContain("Failed during work");
expect(html).not.toMatch(/antigravity:|RESOURCE_EXHAUSTED|HTTP 429/);
});
it("keeps unknown provider ids readable", () => {
const html = render({ schema: "paperclip.provider-failure.v1", provider: "anthropic", phase: "startup", category: "model_unavailable",
message: "Model unavailable.", retryability: "requires_action" });
expect(html).toContain("Claude: Model unavailable");
expect(html).toContain("Failed before work started");
});
+2 -3
View File
@@ -12,15 +12,14 @@ const labels: Record<ProviderFailure["category"], string> = {
export function ProviderFailureNotice({ failure, actions, children, className }: {
failure: ProviderFailure; actions?: ReactNode; children?: ReactNode; className?: string;
}) {
const provider = ({ anthropic: "Claude", openai: "OpenAI", sandbox: "Sandbox provider" } as Record<string, string>)[failure.provider] ?? failure.provider;
const provider = ({ anthropic: "Claude", openai: "OpenAI", antigravity: "Google Antigravity", google: "Google", sandbox: "Sandbox provider" } as Record<string, string>)[failure.provider] ?? failure.provider;
return (
<InlineBanner tone="danger" title={`${provider}: ${labels[failure.category]}`} actions={actions} className={className}>
<div className="flex flex-col gap-2">
<p className="whitespace-pre-wrap break-words">{failure.message}</p>
<p className="text-xs text-muted-foreground">
{/* Provider codes and HTTP statuses stay in the run's diagnostics, not in front of people. */}
{failure.phase === "startup" ? "Failed before work started" : "Failed during work"}
{failure.httpStatus ? ` · HTTP ${failure.httpStatus}` : ""}
{failure.providerCode ? ` · ${failure.providerCode}` : ""}
</p>
{failure.requestId && <p className="font-mono text-xs text-muted-foreground">Request: {failure.requestId}</p>}
{children}
+22
View File
@@ -2850,6 +2850,28 @@ describe("TaskChatThread runtime transcript selection", () => {
},
);
it("shows a refused /swarm in its own plain words, without its code or a Retry", () => {
const plain = "Swarm is not available with Gemini 4 Neon (Low) yet, so nothing was changed: choose another model for this agent, such as Gemini 4 Argon, and send /swarm again.";
renderThread({
comments: [],
onAdd: async () => {},
issueStatus: "blocked",
onRetryFailedRun: vi.fn(),
linkedRuns: [{
runId: "swarm-refused", runtimeMode: "native", status: "failed", errorCode: "antigravity_swarm_unavailable", error: plain,
agentId: "agent-1", agentName: "Runner", adapterType: "paperclip_runner",
createdAt: "2026-11-24T18:00:00.000Z", startedAt: "2026-11-24T18:00:00.000Z", finishedAt: "2026-11-24T18:00:08.000Z",
}],
} as Parameters<typeof renderThread>[0]);
const marker = container.querySelector('[data-testid="task-chat-collapsible-marker"]');
expect(marker?.textContent).toContain("Swarm did not start");
flushSync(() => marker!.querySelector<HTMLButtonElement>('button[aria-expanded="false"]')!.click());
const details = container.querySelector('[data-testid="task-chat-collapsible-marker-details"]')?.textContent ?? "";
expect(details).toContain(plain);
expect(container.textContent).not.toMatch(/antigravity_swarm_unavailable|The runner stopped/);
expect(container.textContent).not.toMatch(/Try again|Retry/);
});
it("does not treat a progress comment as the final response of a failed native run", () => {
nativeTranscriptState.transcriptByRun.set("native-progress-failed", [
assistantEntry("2026-08-25T18:00:01.000Z", "Still working through the provider request.", "progress"),
+7 -1
View File
@@ -1812,6 +1812,8 @@ export function TaskChatThread(props: TaskChatThreadProps) {
? "Runtime missing"
: code === "native_provider_model_rejected" && source.status === "failed"
? "Model unavailable"
: code === "antigravity_swarm_unavailable" && source.status === "failed"
? "Swarm did not start"
: code === "native_provider_approval_required" && source.status === "failed"
? "Approval required"
: code === "native_provider_usage_limit" && source.status === "failed"
@@ -1841,6 +1843,9 @@ export function TaskChatThread(props: TaskChatThreadProps) {
? `${props.interruption?.observedRunId === source.id && props.interruption.rejectedModel
? `The provider rejected the model "${props.interruption.rejectedModel}".`
: meta?.error || "The provider rejected the selected model."} Choose a supported model or clear the task's model override, then retry.`
: code === "antigravity_swarm_unavailable" && source.status === "failed"
// The swarm route's own plain sentence; never the code.
? meta?.error?.trim() || "Swarm did not start, and nothing was changed. Send /swarm again to try once more."
: code === "native_provider_usage_limit" &&
source.status === "failed"
? "The model provider has reached its current usage limit. Try again after the limit resets."
@@ -1871,7 +1876,8 @@ export function TaskChatThread(props: TaskChatThreadProps) {
tone: source.status === "cancelled" ? "neutral" : "error",
label,
detail,
retryable: code !== "native_session_cleanup_quarantined" && !diskFullBesideInterruption,
// A refused /swarm waits for the person (another model, or /swarm again); Retry meets the same refusal.
retryable: code !== "native_session_cleanup_quarantined" && code !== "antigravity_swarm_unavailable" && !diskFullBesideInterruption,
...(credentialAccess ? { credentialAccess, retryable: false } : {}),
collapsible: true,
runId: source.id,