Skip to content

Commit fea5dfc

Browse files
ryush00claude
authored andcommitted
fix(antigravity): offer Auto permission mode when agy ACP advertises it
Antigravity threads set to Auto ran in Supervised: the provider never offered Auto and mapped it to the agent's default mode. That was right for the legacy 1.4 harness, which has no automatic review, but agy acp 1.5.4+ advertises and enforces an auto session mode. Offer Auto from agy 1.5.4, send the session's auto mode when the session advertises it, and leave the prompts the agent still sends to the user. Sessions without auto (the 1.4 harness, Gemini Enterprise accounts) stay in default and are answered as Supervised. Fixes pingdotgg#37082 Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent 282a429 commit fea5dfc

9 files changed

Lines changed: 310 additions & 48 deletions

File tree

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,18 @@ const antigravityModels = [
365365
] satisfies ReadonlyArray<AcpCompat.ModelInfo>;
366366

367367
const availableModes: ReadonlyArray<AcpCompat.SessionMode> = antigravityProfile
368-
? [
369-
{ id: "default", name: "Default" },
370-
{ id: "auto_edit", name: "Auto edit" },
371-
{ id: "yolo", name: "YOLO" },
372-
]
368+
? process.env.T3_ACP_ANTIGRAVITY_CLI_MODES === "1"
369+
? [
370+
{ id: "default", name: "Default" },
371+
{ id: "accept-edits", name: "Accept edits" },
372+
{ id: "auto", name: "Auto" },
373+
{ id: "plan", name: "Plan" },
374+
]
375+
: [
376+
{ id: "default", name: "Default" },
377+
{ id: "auto_edit", name: "Auto edit" },
378+
{ id: "yolo", name: "YOLO" },
379+
]
373380
: copilotModesProfile
374381
? [
375382
{ id: copilotModeId("agent"), name: "Agent" },

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,61 @@ describe("AntigravityAdapterV2 flavor", () => {
102102
assert.equal(launch?.prompt, "Read README.md");
103103
});
104104

105+
it.effect("answers Auto as Supervised only in a session that offers no automatic review", () =>
106+
Effect.gen(function* () {
107+
const modes = (ids: ReadonlyArray<string>) => ({
108+
currentModeId: "default",
109+
availableModes: ids.map((id) => ({ id, name: id })),
110+
});
111+
const sessionModes: Record<string, ReturnType<typeof modes>> = {
112+
personal: modes(["default", "accept-edits", "auto", "plan"]),
113+
enterprise: modes(["default", "accept-edits", "plan"]),
114+
};
115+
const sessions = makeAntigravityAcpAdapterFlavor({
116+
instanceId: ProviderInstanceId.make("antigravity-auto-test"),
117+
random: undefined as never,
118+
fileSystem: undefined as never,
119+
path: undefined as never,
120+
host: { paths: { attachmentsDir: "/attachments" } } as never,
121+
selfInvocation: undefined as never,
122+
// The stub names each session after its workspace.
123+
makeRuntime: (input) =>
124+
Effect.succeed({
125+
start: () =>
126+
Effect.succeed({
127+
sessionId: input.cwd,
128+
sessionSetupResult: { modes: sessionModes[input.cwd] },
129+
}),
130+
} as never),
131+
withProcess: (_stop, task) => task,
132+
defaultModel: Effect.undefined,
133+
});
134+
const policy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
135+
runtimeMode: "auto",
136+
interactionMode: "default",
137+
cwd: "/workspace",
138+
});
139+
const dispositions = (sessionId: string) =>
140+
(["read", "execute"] as const).map((kind) =>
141+
sessions.permissionDisposition?.(policy, {
142+
sessionId,
143+
options: [],
144+
toolCall: { toolCallId: "tool-1", kind },
145+
}),
146+
);
147+
yield* Effect.gen(function* () {
148+
for (const cwd of ["personal", "enterprise"]) {
149+
const runtime = yield* sessions.makeRuntime({ cwd } as never);
150+
yield* runtime.start();
151+
}
152+
// In `auto` every prompt is a review refusal; without it the agent asks before each action.
153+
assert.deepEqual(dispositions("personal"), ["ask", "ask"]);
154+
assert.deepEqual(dispositions("enterprise"), ["allow", "ask"]);
155+
}).pipe(Effect.scoped);
156+
assert.deepEqual(dispositions("enterprise"), ["ask", "ask"]);
157+
}).pipe(Effect.provide(layerSession)),
158+
);
159+
105160
it("routes interaction_* permission requests to the question card", () => {
106161
const question = flavor.extractPermissionQuestion?.(
107162
permissionRequest("interaction_1", [

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import type { AntigravityAuth } from "../../provider/AntigravityAuth.ts";
2121
import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
2222
import {
2323
antigravityAppendsSystemPrompt,
24+
antigravityPermissionDisposition,
2425
antigravityPermissionMode,
2526
antigravityRuntimeModeForSessionMode,
27+
antigravitySessionOffersAutoMode,
2628
applyAntigravityAcpModelSelection,
2729
buildAntigravityPrompt,
2830
type AntigravityAcpRuntimeInput,
@@ -152,6 +154,8 @@ export function makeAntigravityAcpAdapterFlavor(
152154
const { profileDirectory } = options;
153155
const antigravityClientFileRoots = (cwd: string | null) =>
154156
cwd === null ? [options.host.paths.attachmentsDir] : [cwd, options.host.paths.attachmentsDir];
157+
// Gemini Enterprise and the 1.4 harness offer no `auto`; those sessions run Auto as Supervised.
158+
const sessionsWithoutAuto = new Set<string>();
155159
const makeRuntime = Effect.fn("AntigravityAdapterV2.makeRuntime")(
156160
function* (input: AcpAdapterV2RuntimeInput) {
157161
const scope = yield* Scope.fork(yield* Effect.scope);
@@ -203,13 +207,17 @@ export function makeAntigravityAcpAdapterFlavor(
203207
);
204208
},
205209
start: () =>
206-
runtime
207-
.start()
208-
.pipe(
209-
Effect.tap(
210-
(started) => options.onSessionStarted?.(started, input.cwd) ?? Effect.void,
211-
),
212-
),
210+
runtime.start().pipe(
211+
Effect.tap((started) => {
212+
if (antigravitySessionOffersAutoMode(started.sessionSetupResult)) return Effect.void;
213+
sessionsWithoutAuto.add(started.sessionId);
214+
return Scope.addFinalizer(
215+
scope,
216+
Effect.sync(() => sessionsWithoutAuto.delete(started.sessionId)),
217+
);
218+
}),
219+
Effect.tap((started) => options.onSessionStarted?.(started, input.cwd) ?? Effect.void),
220+
),
213221
} satisfies typeof runtime;
214222
},
215223
Effect.provideService(SecureRandom.SecureRandom, options.random),
@@ -265,7 +273,11 @@ export function makeAntigravityAcpAdapterFlavor(
265273
mapError: (cause) => cause,
266274
});
267275
}),
268-
sessionModeForPolicy: (policy) => antigravityPermissionMode(policy.runtimeMode),
276+
sessionModeForPolicy: antigravityPermissionMode,
277+
permissionDisposition: (policy, request) =>
278+
antigravityPermissionDisposition(policy, request, {
279+
offersAuto: !sessionsWithoutAuto.has(request.sessionId),
280+
}),
269281
requiresRuntimeRestartForPolicyChange: (previous, next) =>
270282
(previous.runtimeMode === "full-access") !== (next.runtimeMode === "full-access"),
271283
runtimeModeForSessionMode: antigravityRuntimeModeForSessionMode,

‎apps/server/src/provider/AntigravityProvider.test.ts‎

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,57 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => {
344344
}),
345345
);
346346

347-
it.effect("does not offer Auto, so Auto threads fall back to Supervised", () =>
347+
it.effect("offers Auto only where the agent has automatic review", () =>
348348
Effect.gen(function* () {
349+
const modes = (harness: {
350+
readonly provider: {
351+
readonly snapshot: { readonly getSnapshot: Effect.Effect<ServerProvider> };
352+
};
353+
}) =>
354+
harness.provider.snapshot.getSnapshot.pipe(
355+
Effect.map((snapshot) => snapshot.supportedRuntimeModes),
356+
);
357+
const withoutAuto = ["approval-required", "auto-accept-edits", "full-access"];
358+
const withAuto = ["approval-required", "auto-accept-edits", "auto", "full-access"];
359+
const startedWithModes = (ids: ReadonlyArray<string>) => ({
360+
...started,
361+
sessionSetupResult: {
362+
...sessionSetupResult,
363+
configOptions: [modelConfig],
364+
modes: { currentModeId: "default", availableModes: ids.map((id) => ({ id, name: id })) },
365+
},
366+
});
367+
368+
// The 1.4 harness has no automatic review; the shared ACP policy would approve every request.
349369
const harness = yield* makeHarness();
350370
yield* harness.initialize;
351-
// Antigravity has no automatic review; the shared ACP policy would approve every request.
352-
expect((yield* harness.provider.snapshot.getSnapshot).supportedRuntimeModes).toEqual([
353-
"approval-required",
354-
"auto-accept-edits",
355-
"full-access",
356-
]);
371+
expect(yield* modes(harness)).toEqual(withoutAuto);
372+
yield* harness.provider.onSessionStarted(started);
373+
expect(yield* modes(harness)).toEqual(withoutAuto);
374+
375+
// The agy CLI offers it from 1.5.4, before any session has reported the account's modes.
376+
const cli = yield* makeHarness();
377+
yield* Deferred.succeed(cli.initialProbe, {
378+
...initializeResult,
379+
agentInfo: { ...initializeResult.agentInfo, version: "1.5.6" },
380+
});
381+
yield* cli.initialUpdate;
382+
expect(yield* modes(cli)).toEqual(withAuto);
383+
// Gemini Enterprise omits `auto`, and the next health check must not offer it again.
384+
yield* cli.provider.onSessionStarted(startedWithModes(["default", "accept-edits", "plan"]));
385+
expect(yield* modes(cli)).toEqual(withoutAuto);
386+
yield* cli.provider.snapshot.refresh;
387+
expect(yield* modes(cli)).toEqual(withoutAuto);
388+
// Another account may sign in, so the release decides again until its session reports.
389+
yield* cli.provider.onSignedOut;
390+
expect(yield* modes(cli)).toEqual(withAuto);
391+
392+
const customLauncher = yield* makeHarness();
393+
yield* customLauncher.initialize;
394+
yield* customLauncher.provider.onSessionStarted(
395+
startedWithModes(["default", "accept-edits", "auto", "plan"]),
396+
);
397+
expect(yield* modes(customLauncher)).toEqual(withAuto);
357398
}),
358399
);
359400

‎apps/server/src/provider/AntigravityProvider.ts‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ProviderDriverKind,
55
type AntigravitySettings,
66
type ProviderSetupError,
7+
RuntimeMode,
78
type ServerProvider,
89
type ServerProviderModel,
910
type ServerProviderSlashCommand,
@@ -37,7 +38,11 @@ import {
3738
} from "@t3tools/provider-core/server/snapshotProbe";
3839
import { resolveUsageLimitsAfterProbe } from "@t3tools/provider-core/server/usageLimits";
3940

40-
import { antigravityThinkingConfig } from "./acp/AntigravityAcpSupport.ts";
41+
import {
42+
antigravityReleaseOffersAutoMode,
43+
antigravitySessionOffersAutoMode,
44+
antigravityThinkingConfig,
45+
} from "./acp/AntigravityAcpSupport.ts";
4146

4247
const EMPTY_MODEL_CAPABILITIES = createModelCapabilities({ optionDescriptors: [] });
4348
const MAX_WORKSPACE_SNAPSHOTS = 32;
@@ -187,8 +192,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
187192
presentation: {
188193
displayName: "Antigravity",
189194
showInteractionModeToggle: false,
190-
// No automatic review, so Auto falls back to Supervised instead of approving everything.
191-
supportedRuntimeModes: ["approval-required", "auto-accept-edits", "full-access"],
195+
supportedRuntimeModes: RuntimeMode.literals.filter((mode) => mode !== "auto"),
192196
},
193197
enabled: settings.enabled,
194198
checkedAt,
@@ -225,6 +229,13 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
225229
thinkingLevels.set(model.currentValue, antigravityThinkingConfig(configOptions) ?? null);
226230
}
227231
};
232+
// Whether the account's last session offered `auto`; Gemini Enterprise and the 1.4 harness do
233+
// not. Until a session reports, the release decides. Unoffered, Auto falls back to Supervised.
234+
let sessionOffersAuto: boolean | undefined;
235+
const runtimeModes = (version: string | null) => {
236+
const offersAuto = sessionOffersAuto ?? antigravityReleaseOffersAutoMode(version);
237+
return RuntimeMode.literals.filter((mode) => mode !== "auto" || offersAuto);
238+
};
228239
const getSnapshot = SubscriptionRef.get(metadata).pipe(
229240
Effect.flatMap((state) => options.stampIdentity(state.draft)),
230241
);
@@ -301,6 +312,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
301312
if (state.authRevision !== before.authRevision) return state;
302313
const { message: _previousMessage, ...draft } = state.draft;
303314
const authenticated = draft.auth.status === "authenticated";
315+
const resolvedVersion = version === "unknown" ? draft.version : version || draft.version;
304316
const message =
305317
errorMessage ??
306318
(authenticated
@@ -314,7 +326,8 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
314326
...draft,
315327
installed: !missingInstallation,
316328
// Lightweight custom-launcher probes lack versions; preserve the real handshake's version.
317-
version: version === "unknown" ? draft.version : version || draft.version,
329+
version: resolvedVersion,
330+
supportedRuntimeModes: runtimeModes(resolvedVersion),
318331
status: errorMessage ? "error" : authenticated ? "ready" : "warning",
319332
checkedAt: updatedAt,
320333
usageLimits: missingInstallation ? undefined : draft.usageLimits,
@@ -379,16 +392,19 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
379392
) {
380393
return state;
381394
}
395+
sessionOffersAuto = antigravitySessionOffersAutoMode(started.sessionSetupResult);
382396
const { message: _previousMessage, ...draft } = state.draft;
383397
const workspaces = draft.workspaceSnapshots ?? [];
384398
const workspace = cwd ? workspaces.find((entry) => entry.cwd === cwd) : undefined;
399+
const version = started.initializeResult.agentInfo?.version || draft.version;
385400
return {
386401
authRevision: state.authRevision + 1,
387402
draft: {
388403
...draft,
389404
installed: true,
390405
status: "ready",
391-
version: started.initializeResult.agentInfo?.version || draft.version,
406+
version,
407+
supportedRuntimeModes: runtimeModes(version),
392408
auth: {
393409
status: "authenticated",
394410
type: options.auth?.type ?? "oauth-personal",
@@ -466,13 +482,15 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
466482
yield* resetUsage;
467483
if (!settings.enabled) return;
468484
const updatedAt = DateTime.formatIso(yield* DateTime.now);
485+
sessionOffersAuto = undefined;
469486
yield* SubscriptionRef.update(
470487
metadata,
471488
(state) =>
472489
({
473490
authRevision: state.authRevision + 1,
474491
draft: {
475492
...state.draft,
493+
supportedRuntimeModes: runtimeModes(state.draft.version),
476494
auth: {
477495
status: "unauthenticated",
478496
...(usesCredentials ? options.auth : {}),

‎apps/server/src/provider/Drivers/AntigravityDriver.test.ts‎

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
8888
/** `data` of the agent's "Internal error" response to `session/new`. */
8989
readonly newSessionErrorData?: unknown;
9090
readonly initialMode?: string;
91+
/** Advertise the agy CLI's modes, which include `auto`, instead of the 1.4 harness's. */
92+
readonly cliModes?: boolean;
9193
} = {},
9294
) {
9395
const directory = path.join(root, name);
@@ -111,6 +113,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
111113
...(options.initialMode === undefined
112114
? []
113115
: [`export T3_ACP_INITIAL_MODE=${shellQuote(options.initialMode)}`]),
116+
...(options.cliModes ? ["export T3_ACP_ANTIGRAVITY_CLI_MODES=1"] : []),
114117
`exec ${shellQuote(nodePath)} ${shellQuote(mockAgentPath)} "$@"`,
115118
"",
116119
].join("\n"),
@@ -416,17 +419,29 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
416419
...(yield* h.makeExecutable("runtime cli", { initialMode: "auto_edit" })),
417420
harnessPath: null,
418421
};
419-
for (const runtimeMode of ["full-access", "auto-accept-edits"] as const) {
422+
const cliWithAuto = {
423+
...(yield* h.makeExecutable("runtime cli auto", { cliModes: true })),
424+
harnessPath: null,
425+
};
426+
// Auto runs the agent's own review where the session offers it; elsewhere the agent asks.
427+
for (const [runtimeMode, executable, sessionModes] of [
428+
["full-access", h.controls.selected, ["default"]],
429+
["auto-accept-edits", h.controls.selected, ["default"]],
430+
["auto", h.controls.selected, ["default"]],
431+
["auto", h.second, []],
432+
["auto", cliWithAuto, ["auto"]],
433+
] as const) {
434+
h.controls.selected = executable;
420435
const requestsBefore = (yield* h.readRequests).length;
421-
const cliThreadId = ThreadId.make(`thread-antigravity-cli-${runtimeMode}`);
436+
const cliThreadId = ThreadId.make(`thread-antigravity-cli-${requestsBefore}`);
422437
const cliPolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
423438
runtimeMode,
424439
interactionMode: "default",
425440
cwd: workspace,
426441
});
427442
const cliSession = yield* h.instance.orchestrationAdapter.openSession({
428443
threadId: cliThreadId,
429-
providerSessionId: ProviderSessionId.make(`provider-session-cli-${runtimeMode}`),
444+
providerSessionId: ProviderSessionId.make(`provider-session-cli-${requestsBefore}`),
430445
modelSelection,
431446
runtimePolicy: cliPolicy,
432447
});
@@ -435,14 +450,16 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
435450
modelSelection,
436451
runtimePolicy: cliPolicy,
437452
});
438-
expect(h.launches.at(-1)?.args).toEqual([
439-
"acp",
440-
"--gemini-dir",
441-
h.profileDirectory,
442-
"--app-data-dir",
443-
"antigravity-acp",
444-
...(runtimeMode === "full-access" ? ["--dangerously-skip-permissions"] : []),
445-
]);
453+
if (executable.harnessPath === null) {
454+
expect(h.launches.at(-1)?.args).toEqual([
455+
"acp",
456+
"--gemini-dir",
457+
h.profileDirectory,
458+
"--app-data-dir",
459+
"antigravity-acp",
460+
...(runtimeMode === "full-access" ? ["--dangerously-skip-permissions"] : []),
461+
]);
462+
}
446463
expect(
447464
(yield* h.readRequests)
448465
.slice(requestsBefore)
@@ -452,7 +469,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
452469
request.params?.configId === "mode",
453470
)
454471
.map((request) => request.params?.value),
455-
).toEqual(["default"]);
472+
).toEqual(sessionModes);
456473
}
457474
}),
458475
);

0 commit comments

Comments
 (0)