fix(runner): omit provider mode from ordinary Antigravity ACP runtime identity (#23536)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Paperclip Runner executes Google Antigravity agents through
`AcpxRuntimeHost` and the unified `agy acp` 1.5.19 runtime
(`openAntigravityAcpRuntime`)
> - After #23168 moved ordinary Antigravity turns onto
`openAntigravityAcpRuntime`, its `identity()` method hardcoded `mode:
"persistent"`, confusing ACPX session persistence with
`AcpxRuntimePortIdentity.mode` (the optional provider mode)
> - Ordinary Antigravity turns resolve `binding.mode` to `undefined`, so
`AcpxRuntimeHost.open()` rejected every ordinary Antigravity run during
identity admission with `ACPX_ADMISSION_IDENTITY` (`ACPX runtime
Provider mode does not match the admitted session configuration`)
> - This pull request omits `mode` from `openAntigravityAcpRuntime`'s
`identity()`, rejects unexpected provider modes passed directly to
`openAntigravityAcpRuntime`, and adds an `AcpxRuntimeHost.open()`
fresh-open and session-resume regression test
> - The benefit is that ordinary Google Antigravity runs pass admission
and resume cleanly on both local and remote runners

## Linked Issues or Issue Description

Refs #23168

**What happened?**
Every ordinary (non-`/swarm`) Google Antigravity run failed during
`session.open` admission with `ACPX_ADMISSION_IDENTITY`: `ACPX runtime
Provider mode does not match the admitted session configuration`.
`openAntigravityAcpRuntime` returned `mode: "persistent"` from
`identity()`, while `AcpxRuntimeHost.open()` bound `binding.mode` to
`undefined` via `resolveAcpxProviderMode("antigravity", undefined)`.

**Expected behavior**
Ordinary Antigravity runs omit `mode` (`undefined`) in
`AcpxRuntimePortIdentity`, matching `binding.mode` during both initial
`AcpxRuntimeHost.open()` admission and subsequent `expectedIdentity`
session resume. Only trusted `/swarm` turns (served by
`openAntigravitySwarmRuntime`) carry `mode: "swarm"`.

**Steps to reproduce**
1. Open an ordinary Antigravity session (`mode: undefined`) through
`AcpxRuntimeHost.open()` backed by `openAntigravityAcpRuntime`.
2. Observe `AcpxRuntimeHost.open()` throw `ACPX runtime Provider mode
does not match the admitted session configuration` at `runtime-host.ts`
during identity verification.

**Paperclip version or commit**
`4db307d53c` (`master`, regression introduced in `3df59a1853` / #23168)

**Deployment mode**
Self-hosted server

## What Changed

- Remove hardcoded `mode: "persistent"` from
`openAntigravityAcpRuntime`'s `identity()` return value in
`packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.ts`
so `runtimeIdentity.mode` is `undefined` and matches `binding.mode` for
ordinary turns.
- Fail closed in `openAntigravityAcpRuntime` if a caller passes a
non-`undefined` `options.mode`.
- Add red-green regression tests in
`packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`
covering `AcpxRuntimeHost.open()` admission, `expectedIdentity` session
resume, and direct non-empty `mode` rejection.
- Update the ordinary-route identity expectation in
`packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-route.test.ts`
from `mode: "persistent"` to `mode: undefined`.

## Verification

- Reproduced the exact failure before the fix: `AcpxRuntimeHost.open()`
threw `ACPX runtime Provider mode does not match the admitted session
configuration` on the new regression test in
`packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`.
- Verified green after the fix:
- `pnpm --dir packages/paperclip-runner exec vitest run
src/drivers/acpx/antigravity-acp-runtime.test.ts
src/drivers/acpx/antigravity-swarm-route.test.ts
src/drivers/acpx/antigravity-admission.test.ts
src/drivers/acpx/antigravity-acpx-runtime.test.ts
src/drivers/acpx/antigravity-credentials.test.ts
src/drivers/acpx/antigravity-swarm-guard.test.ts
src/cli/acpx-runtime-sidecar.test.ts` (7 test files, 244 tests passed)
- `pnpm --dir packages/paperclip-runner exec vitest run
src/drivers/acpx/antigravity-swarm-runtime.test.ts
src/drivers/acpx/runtime-host.test.ts` (157 tests passed)
- `pnpm --dir packages/paperclip-runner typecheck` (TypeScript + Rust
checks passed)
- Live remote staging execution requires deploying this fix; local
verification exercised the real `AcpxRuntimeHost` admission, binding,
and resume boundary with the ordinary Antigravity ACP fixture.

## Risks

- Low risk. The change aligns `openAntigravityAcpRuntime`'s reported
identity with `AcpxRuntimeHost`'s existing provider-mode contract
(`acpx-runtime-adapter.ts` already omits `mode` when no provider mode is
active). `/swarm` turns still route through
`openAntigravitySwarmRuntime` and report `mode: "swarm"`.

## Model Used

- Google Gemini 4 Neon (Medium) via Antigravity agent with tool use and
local code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-12-02 13:42:53 -06:00
1 parent c655f38b72
commit f5f47b1ec4
3 files changed
+77 -3

No files matched your search

@@ -8,7 +8,8 @@ import { AntigravitySavedStateIncompatibleError } from "./antigravity-admission.
import { AntigravityAcpError, openAntigravityAcpRuntime } from "./antigravity-acp-runtime.js";
import { ANTIGRAVITY_RUNTIME_VERSION } from "./generated-profiles.js";
import { QUALIFIED_ACPX_PROFILES } from "./qualified-profiles.js";
import type { AcpxRuntimePortOpenOptions } from "./runtime-host.js";
import { acpxProviderSessionIdentity } from "./recovery-identity.js";
import { AcpxRuntimeHost, type AcpxRuntimePortOpenOptions } from "./runtime-host.js";
import { withAcpxTurnCancellation } from "./turn-cancellation.js";
const roots: string[] = [];
@@ -526,4 +527,73 @@ describe("openAntigravityAcpRuntime (unified agy acp 1.5.19 ordinary turns)", ()
await runtime.close({ reason: "cleanup" }).catch(() => undefined);
}
}, 15_000);
it("passes AcpxRuntimeHost admission and resume for ordinary turns without a provider mode", async () => {
const { root, cwd, logFile, openOptions } = await makeFixture("ok");
const runtimeDirectory = join(root, "runtime");
const { mkdir } = await import("node:fs/promises");
await mkdir(runtimeDirectory, { recursive: true });
const baseCommand = openOptions().command;
const dependencies = {
verifyInstallation: async () => ({
commandDigest: QUALIFIED_ACPX_PROFILES.antigravity.commandDigest,
agentServerPackageJsonPath: null,
agentRuntimePackageJsonPath: null,
openCommand: async () => baseCommand,
}),
openRuntime: (opts: AcpxRuntimePortOpenOptions) =>
openAntigravityAcpRuntime(opts, { awaitProviderOwnership: async () => undefined }),
reportRetainedCleanupFailure: () => undefined,
};
const hostOptions = {
runtimeDirectory,
normalizedSessionId: "antigravity-ordinary-host-session",
workingDirectory: cwd,
agent: "antigravity" as const,
model: "gemini-4-argon-medium",
permissionMode: "approve-all" as const,
environment: { GEMINI_API_KEY: "test-antigravity-key" },
};
const first = await AcpxRuntimeHost.open(hostOptions, dependencies);
let expectedIdentity: ReturnType<typeof acpxProviderSessionIdentity>;
try {
expect(first.identity().mode).toBeUndefined();
expect(first.identity().backendSessionId).toBe("sess-ordinary-1");
expectedIdentity = acpxProviderSessionIdentity(first.identity(), first.binding());
expect(expectedIdentity.mode).toBeUndefined();
} finally {
await first.close({ reason: "first turn done" });
}
const resumed = await AcpxRuntimeHost.open(
{ ...hostOptions, expectedIdentity },
dependencies,
);
try {
expect(resumed.identity().mode).toBeUndefined();
expect(resumed.identity().backendSessionId).toBe("sess-ordinary-1");
} finally {
await resumed.close({ reason: "resumed turn done" });
}
const rpcLog = (await readFile(logFile, "utf8"))
.trim()
.split("\n")
.map(line => JSON.parse(line) as { method?: string; params?: { sessionId?: string } });
expect(rpcLog.filter(entry => entry.method === "session/new")).toHaveLength(1);
expect(rpcLog.filter(entry => entry.method === "session/resume")).toEqual([
expect.objectContaining({
method: "session/resume",
params: expect.objectContaining({ sessionId: "sess-ordinary-1" }),
}),
]);
});
it("rejects non-empty provider mode passed directly to openAntigravityAcpRuntime", async () => {
const { openOptions } = await makeFixture("ok");
await expect(
openAntigravityAcpRuntime(openOptions({ mode: "swarm" }), { awaitProviderOwnership: async () => undefined }),
).rejects.toThrow(/provider mode|ordinary/i);
});
});
@@ -201,6 +201,9 @@ export async function openAntigravityAcpRuntime(
if (options.profile.agent !== "antigravity") {
throw new Error("The Antigravity ACP runtime serves only the Antigravity profile");
}
if (options.mode !== undefined) {
throw new Error("The Antigravity ACP runtime serves only ordinary turns without a provider mode");
}
options.signal?.throwIfAborted();
const requestTimeoutMs = dependencies.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
const readbackTimeoutMs = dependencies.readbackTimeoutMs ?? DEFAULT_READBACK_TIMEOUT_MS;
@@ -559,7 +562,6 @@ export async function openAntigravityAcpRuntime(
return {
async identity(): Promise<AcpxRuntimePortIdentity> {
return {
mode: "persistent",
acpxRecordId: `antigravity-cli:${options.providerSessionKey}`,
backendSessionId: sessionId,
agentSessionId: sessionId,
@@ -111,7 +111,9 @@ describe("Antigravity swarm route selection", () => {
} as unknown as AcpxRuntimePortOpenOptions, {
createRuntime: () => { throw new Error("ordinary Antigravity turns must not enter ACPX"); },
});
expect(await runtime.identity()).toMatchObject({ mode: "persistent" });
const identity = await runtime.identity();
expect(identity.mode).toBeUndefined();
expect(identity.acpxRecordId).toBe("antigravity-cli:key");
await runtime.close({ reason: "done" });
});
});