diff --git a/server/src/services/native-runtime/native-session-executor.test.ts b/server/src/services/native-runtime/native-session-executor.test.ts index a0d9dcc2371..c1b507258bd 100644 --- a/server/src/services/native-runtime/native-session-executor.test.ts +++ b/server/src/services/native-runtime/native-session-executor.test.ts @@ -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); diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index dc21c242f90..ebb185180d3 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -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 diff --git a/server/src/services/task-interruption-presentation.test.ts b/server/src/services/task-interruption-presentation.test.ts index 56c6348f733..23ccef5b1fb 100644 --- a/server/src/services/task-interruption-presentation.test.ts +++ b/server/src/services/task-interruption-presentation.test.ts @@ -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", diff --git a/server/src/services/task-interruption-presentation.ts b/server/src/services/task-interruption-presentation.ts index ab4d536ea91..52f7bb50ddf 100644 --- a/server/src/services/task-interruption-presentation.ts +++ b/server/src/services/task-interruption-presentation.ts @@ -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 } : {}) }; } diff --git a/ui/src/components/ProviderFailureNotice.test.tsx b/ui/src/components/ProviderFailureNotice.test.tsx new file mode 100644 index 00000000000..32e809e5440 --- /dev/null +++ b/ui/src/components/ProviderFailureNotice.test.tsx @@ -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(); + +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"); +}); diff --git a/ui/src/components/ProviderFailureNotice.tsx b/ui/src/components/ProviderFailureNotice.tsx index 03198ea690b..b22edd83946 100644 --- a/ui/src/components/ProviderFailureNotice.tsx +++ b/ui/src/components/ProviderFailureNotice.tsx @@ -12,15 +12,14 @@ const labels: Record = { 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)[failure.provider] ?? failure.provider; + const provider = ({ anthropic: "Claude", openai: "OpenAI", antigravity: "Google Antigravity", google: "Google", sandbox: "Sandbox provider" } as Record)[failure.provider] ?? failure.provider; return (

{failure.message}

+ {/* 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}` : ""}

{failure.requestId &&

Request: {failure.requestId}

} {children} diff --git a/ui/src/components/TaskChatThread.test.tsx b/ui/src/components/TaskChatThread.test.tsx index ef337fa382e..00c934b8be6 100644 --- a/ui/src/components/TaskChatThread.test.tsx +++ b/ui/src/components/TaskChatThread.test.tsx @@ -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[0]); + const marker = container.querySelector('[data-testid="task-chat-collapsible-marker"]'); + expect(marker?.textContent).toContain("Swarm did not start"); + flushSync(() => marker!.querySelector('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"), diff --git a/ui/src/components/TaskChatThread.tsx b/ui/src/components/TaskChatThread.tsx index 77f0ce220cb..52ca57d6fab 100644 --- a/ui/src/components/TaskChatThread.tsx +++ b/ui/src/components/TaskChatThread.tsx @@ -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,