Skip to content

Commit ad6f67e

Browse files
t3dotggclaude
andcommitted
feat(antigravity): runtime 1.4.1 with Claude/GPT models and thinking levels
Pin the managed runtime to 1.4.1. Later 1.4.x builds write skills/system/run-workflow/SKILL.md into every session workspace. Identify as Zed so the agent offers the Claude and GPT models it only lists for allowlisted clients. Runtime 1.4 lists model families with a separate thinking level, so each model now gets a thinking picker with the levels it reports, learned by walking the models during catalog refresh. Saved 1.3 IDs such as gemini-3.8-flash-high map to the family plus that level, so existing threads keep working. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent daab663 commit ad6f67e

12 files changed

Lines changed: 228 additions & 47 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,15 @@ describe("AntigravityAdapterV2 client file system", () => {
207207
(line) =>
208208
JSON.parse(line) as {
209209
method?: string;
210-
params?: { clientCapabilities?: { fs?: unknown } };
210+
params?: { clientCapabilities?: { fs?: unknown }; clientInfo?: { name?: string } };
211211
},
212212
)
213213
.find((request) => request.method === "initialize");
214214
assert.deepEqual(initialize?.params?.clientCapabilities?.fs, {
215215
readTextFile: true,
216216
writeTextFile: false,
217217
});
218+
assert.equal(initialize?.params?.clientInfo?.name, "zed");
218219
assert.isUndefined(writeTextFile);
219220
if (readTextFile === undefined) {
220221
return yield* Effect.die("Antigravity sessions must serve client file reads");

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
398398
}),
399399
)
400400
: spawner,
401-
clientInfo: { name: "t3-code", version: "0.0.0" },
402401
});
403402
const initialized = yield* runtime.initialize();
404403
if (

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,50 @@ describe("Antigravity model catalog", () => {
214214
"gemini-pro-agent",
215215
);
216216
});
217+
218+
it("offers each model the thinking levels it reported when selected", () => {
219+
const thinking = (currentValue: string) =>
220+
({
221+
id: "thinking_level",
222+
name: "Thinking Level",
223+
category: "thought_level",
224+
type: "select",
225+
currentValue,
226+
options: [
227+
{ value: "low", name: "Low" },
228+
{ value: "high", name: "High" },
229+
],
230+
}) satisfies EffectAcpSchema.SessionConfigOption;
231+
const models = buildAntigravityModelsFromSession(
232+
{
233+
configOptions: [
234+
{
235+
...modelConfig,
236+
currentValue: "gemini",
237+
options: [
238+
{ value: "gemini", name: "Gemini" },
239+
{ value: "claude", name: "Claude" },
240+
{ value: "plain", name: "Plain" },
241+
{ value: "unseen", name: "Unseen" },
242+
],
243+
},
244+
thinking("high"),
245+
],
246+
},
247+
new Map([
248+
["claude", thinking("low")],
249+
["plain", null],
250+
]),
251+
);
252+
const thinkingOf = (slug: string) =>
253+
models.find((model) => model.slug === slug)?.capabilities?.optionDescriptors?.[0];
254+
255+
expect(thinkingOf("gemini")).toMatchObject({ id: "thinking_level", currentValue: "high" });
256+
expect(thinkingOf("claude")).toMatchObject({ id: "thinking_level", currentValue: "low" });
257+
expect(thinkingOf("plain")).toBeUndefined();
258+
expect(thinkingOf("unseen")).toMatchObject({ id: "thinking_level" });
259+
expect(thinkingOf("unseen")).not.toHaveProperty("currentValue");
260+
});
217261
});
218262

219263
it.layer(layerTest)("Antigravity provider snapshots", (it) => {

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type * as EffectAcpErrors from "effect-acp/errors";
2020
import type * as EffectAcpSchema from "effect-acp/compat";
2121

2222
import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
23+
import { acpProviderOptionDescriptors } from "@t3tools/provider-acp/server/sessionConfig";
2324
import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider";
2425
import {
2526
makeManualOnlyProviderMaintenanceCapabilities,
@@ -32,6 +33,8 @@ import {
3233
} from "@t3tools/provider-core/server/snapshotProbe";
3334
import { resolveUsageLimitsAfterProbe } from "@t3tools/provider-core/server/usageLimits";
3435

36+
import { antigravityThinkingConfig } from "./acp/AntigravityAcpSupport.ts";
37+
3538
const EMPTY_MODEL_CAPABILITIES = createModelCapabilities({ optionDescriptors: [] });
3639
const MAX_WORKSPACE_SNAPSHOTS = 32;
3740
const HEALTH_CHECK_TIMEOUT = "90 seconds";
@@ -44,8 +47,24 @@ type SessionSetupResult = Pick<
4447
"configOptions" | "models"
4548
>;
4649

50+
type ThinkingConfig = NonNullable<ReturnType<typeof antigravityThinkingConfig>>;
51+
52+
/** Thinking options each model reported when selected; `null` means it has none. */
53+
export type AntigravityThinkingLevels = ReadonlyMap<string, ThinkingConfig | null>;
54+
55+
function thinkingCapabilities(config: ThinkingConfig | null | undefined, observed: boolean) {
56+
const descriptor = config
57+
? acpProviderOptionDescriptors({ configOptions: [config], modeState: undefined })[0]
58+
: undefined;
59+
if (descriptor?.type !== "select") return EMPTY_MODEL_CAPABILITIES;
60+
// Another model's selected level is not this model's default.
61+
const { currentValue: _currentValue, ...unobserved } = descriptor;
62+
return createModelCapabilities({ optionDescriptors: [observed ? descriptor : unobserved] });
63+
}
64+
4765
export function buildAntigravityModelsFromSession(
4866
setup: SessionSetupResult,
67+
thinkingLevels: AntigravityThinkingLevels = new Map(),
4968
): ReadonlyArray<ServerProviderModel> {
5069
const config = setup.configOptions?.find(
5170
(option) => option.id === "model" || option.category === "model",
@@ -61,10 +80,13 @@ export function buildAntigravityModelsFromSession(
6180
name: model.name,
6281
})) ?? [])
6382
: [];
83+
const currentThinking = antigravityThinkingConfig(setup.configOptions);
6484
const seen = new Set<string>();
6585
return entries.flatMap((entry): ServerProviderModel[] => {
6686
if (!entry.value.trim() || seen.has(entry.value)) return [];
6787
seen.add(entry.value);
88+
const observed =
89+
entry.value === currentValue ? (currentThinking ?? null) : thinkingLevels.get(entry.value);
6890
return [
6991
{
7092
slug: entry.value,
@@ -73,7 +95,10 @@ export function buildAntigravityModelsFromSession(
7395
...(entry.value === currentValue
7496
? { isDefault: true, aliases: [ANTIGRAVITY_DEFAULT_MODEL] }
7597
: {}),
76-
capabilities: EMPTY_MODEL_CAPABILITIES,
98+
capabilities:
99+
observed === undefined
100+
? thinkingCapabilities(currentThinking, false)
101+
: thinkingCapabilities(observed, true),
77102
},
78103
];
79104
});
@@ -162,6 +187,17 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
162187
});
163188
// Preserve disk-discovered skills when callbacks replace workspace commands; the registry will not rescan them.
164189
const discoveredSkills = new Map<string, ServerProvider["skills"]>();
190+
const thinkingLevels = new Map<string, ThinkingConfig | null>();
191+
const observeThinkingLevels = (
192+
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption> | null | undefined,
193+
) => {
194+
const model = configOptions?.find(
195+
(option) => option.id === "model" || option.category === "model",
196+
);
197+
if (model?.type === "select" && model.currentValue) {
198+
thinkingLevels.set(model.currentValue, antigravityThinkingConfig(configOptions) ?? null);
199+
}
200+
};
165201
const getSnapshot = SubscriptionRef.get(metadata).pipe(
166202
Effect.flatMap((state) => options.stampIdentity(state.draft)),
167203
);
@@ -267,6 +303,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
267303
cwd?: string,
268304
) {
269305
if (!settings.enabled) return;
306+
observeThinkingLevels(started.sessionSetupResult.configOptions);
270307
const before = yield* SubscriptionRef.get(metadata);
271308
const supportsTextGeneration = yield* options.supportsTextGeneration;
272309
const usageLimits =
@@ -301,7 +338,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
301338
published: draft.usageLimits,
302339
probed: usageLimits ?? draft.usageLimits,
303340
}),
304-
models: buildAntigravityModelsFromSession(started.sessionSetupResult),
341+
models: buildAntigravityModelsFromSession(started.sessionSetupResult, thinkingLevels),
305342
supportsTextGeneration,
306343
...(cwd
307344
? {
@@ -324,7 +361,8 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
324361
const onConfigOptionsUpdated = Effect.fn("AntigravityProvider.onConfigOptionsUpdated")(function* (
325362
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>,
326363
) {
327-
const models = buildAntigravityModelsFromSession({ configOptions });
364+
observeThinkingLevels(configOptions);
365+
const models = buildAntigravityModelsFromSession({ configOptions }, thinkingLevels);
328366
yield* SubscriptionRef.update(metadata, (state) => {
329367
if (state.draft.auth.status !== "authenticated") return state;
330368
return { ...state, draft: { ...state.draft, models } };
@@ -391,6 +429,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
391429
}) satisfies AntigravityProviderState,
392430
);
393431
discoveredSkills.clear();
432+
thinkingLevels.clear();
394433
});
395434

396435
const snapshotForCwd = Effect.fn("AntigravityProvider.snapshotForCwd")(function* (

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import {
3838
type AntigravityAuthConfig,
3939
} from "../antigravityAuthSupport.ts";
4040
import {
41+
antigravityModelOptions,
42+
antigravityThinkingConfig,
4143
makeAntigravityAcpRuntime,
4244
type AntigravityAcpRuntimeInput,
4345
} from "../acp/AntigravityAcpSupport.ts";
@@ -294,7 +296,6 @@ export const AntigravityDriver: ProviderDriver<
294296
);
295297
const runtime = yield* makeRuntime({
296298
cwd,
297-
clientInfo: { name: "t3-code-provider-setup", version: "0.0.0" },
298299
mcpServers: [],
299300
...(input.onAuthorizationUrl ? { onAuthorizationUrl: input.onAuthorizationUrl } : {}),
300301
});
@@ -313,7 +314,10 @@ export const AntigravityDriver: ProviderDriver<
313314

314315
const publishCatalog = Effect.fn("AntigravityDriver.publishCatalog")(function* (
315316
started: AcpSessionRuntime.AcpSessionRuntimeStartResult,
316-
runtime: Pick<AcpSessionRuntime.AcpSessionRuntime["Service"], "getEvents" | "drainEvents">,
317+
runtime: Pick<
318+
AcpSessionRuntime.AcpSessionRuntime["Service"],
319+
"getEvents" | "drainEvents" | "setModel"
320+
>,
317321
) {
318322
yield* provider.onSessionStarted(started);
319323
yield* Stream.runForEach(runtime.getEvents(), (event) => {
@@ -327,6 +331,14 @@ export const AntigravityDriver: ProviderDriver<
327331
? provider.onAvailableCommands(event.availableCommands)
328332
: Effect.void;
329333
}).pipe(Effect.forkScoped);
334+
// Thinking levels differ per model and are reported only for the selected one.
335+
const configOptions = started.sessionSetupResult.configOptions ?? [];
336+
const current = configOptions.find((option) => option.id === "model")?.currentValue;
337+
if (antigravityThinkingConfig(configOptions) !== undefined && typeof current === "string") {
338+
for (const model of [...antigravityModelOptions(configOptions), { value: current }]) {
339+
yield* runtime.setModel(model.value).pipe(Effect.ignore);
340+
}
341+
}
330342
yield* runtime.drainEvents;
331343
}, Effect.scoped);
332344

@@ -439,7 +451,6 @@ export const AntigravityDriver: ProviderDriver<
439451
makeRuntime: (cwd) =>
440452
makeRuntime({
441453
cwd,
442-
clientInfo: { name: "t3-code-text", version: "0.0.0" },
443454
mcpServers: [],
444455
}),
445456
});

‎apps/server/src/provider/acp/AntigravityAcpSupport.test.ts‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ function makeModelRuntime(
3838
if (failure) return yield* failure;
3939
selections.push(model);
4040
});
41+
const setConfigOption = Effect.fn("AntigravityAcpSupportTest.setConfigOption")(function* (
42+
configId: string,
43+
value: string | boolean,
44+
) {
45+
selections.push(`${configId}=${String(value)}`);
46+
return { configOptions };
47+
});
4148
return {
42-
runtime: { getConfigOptions: Effect.succeed(configOptions), setModel },
49+
runtime: { getConfigOptions: Effect.succeed(configOptions), setModel, setConfigOption },
4350
selections,
4451
};
4552
}
@@ -137,6 +144,33 @@ describe("applyAntigravityAcpModelSelection", () => {
137144
expect(selections).toEqual(["gemini-saved"]);
138145
}),
139146
);
147+
148+
it.effect("maps a model ID saved on runtime 1.3 to the 1.4 model and thinking level", () =>
149+
Effect.gen(function* () {
150+
const { runtime, selections } = makeModelRuntime([
151+
{ ...modelConfig, options: [{ value: "gemini-3.8-flash", name: "Gemini 3.8 Flash" }] },
152+
{
153+
id: "thinking_level",
154+
name: "Thinking Level",
155+
category: "thought_level",
156+
type: "select",
157+
currentValue: "high",
158+
options: [
159+
{ value: "low", name: "Low" },
160+
{ value: "high", name: "High" },
161+
],
162+
},
163+
]);
164+
const model = yield* applyAntigravityAcpModelSelection({
165+
runtime,
166+
model: "gemini-3.8-flash-low",
167+
mapError: (cause) => cause,
168+
});
169+
170+
expect(model).toBe("gemini-3.8-flash");
171+
expect(selections).toEqual(["gemini-3.8-flash", "thinking_level=low"]);
172+
}),
173+
);
140174
});
141175

142176
const imageAttachment = {

‎apps/server/src/provider/acp/AntigravityAcpSupport.ts‎

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface AntigravityAcpRuntimeInput extends Omit<
3131
| "authenticateEagerly"
3232
| "cancelBehavior"
3333
| "clientCapabilities"
34+
| "clientInfo"
3435
| "onStderr"
3536
| "resumeMethod"
3637
| "transformSessionUpdate"
@@ -56,6 +57,8 @@ export const makeAntigravityAcpRuntime = Effect.fn("makeAntigravityAcpRuntime")(
5657
authenticateEagerly: true,
5758
resumeMethod: "resume",
5859
cancelBehavior: "wait-for-prompt",
60+
// The agent offers non-Gemini models only to allowlisted clients such as Zed.
61+
clientInfo: { name: "zed", version: "0.0.0" },
5962
clientCapabilities: {
6063
// Advertising writes swaps the agent's diff edits for whole-file client_edit_file.
6164
fs: { readTextFile: input.clientFileReads === true, writeTextFile: false },
@@ -89,14 +92,43 @@ export function antigravityPermissionMode(runtimeMode: RuntimeMode): string {
8992
}
9093
}
9194

92-
function antigravityModelOptions(
95+
export function antigravityModelOptions(
9396
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>,
9497
) {
9598
const model = configOptions.find((option) => option.id === "model");
9699
if (model?.type !== "select") return [];
97100
return model.options.flatMap((entry) => ("value" in entry ? [entry] : entry.options));
98101
}
99102

103+
/** Runtime 1.4 reports thinking as its own option; 1.3 encoded it in the model ID. */
104+
export function antigravityThinkingConfig(
105+
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption> | null | undefined,
106+
) {
107+
const option = configOptions?.find((candidate) => candidate.category === "thought_level");
108+
return option?.type === "select" ? option : undefined;
109+
}
110+
111+
/** Splits a saved 1.3 ID such as `gemini-3.8-flash-high` into a 1.4 model and thinking level. */
112+
function splitLegacyAntigravityModel(
113+
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>,
114+
model: string,
115+
) {
116+
const thinking = antigravityThinkingConfig(configOptions);
117+
if (thinking === undefined) return undefined;
118+
const models = antigravityModelOptions(configOptions);
119+
for (const level of thinking.options.flatMap((entry) =>
120+
"value" in entry ? [entry] : entry.options,
121+
)) {
122+
const family = model.endsWith(`-${level.value}`)
123+
? model.slice(0, -level.value.length - 1)
124+
: undefined;
125+
if (family !== undefined && models.some((option) => option.value === family)) {
126+
return { model: family, thinkingConfigId: thinking.id, thinkingLevel: level.value };
127+
}
128+
}
129+
return undefined;
130+
}
131+
100132
function resolveAntigravityModel(input: {
101133
readonly configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
102134
readonly model: string | null | undefined;
@@ -106,7 +138,9 @@ function resolveAntigravityModel(input: {
106138
const current = modelConfig?.type === "select" ? modelConfig.currentValue : undefined;
107139
if (input.model && input.model !== ANTIGRAVITY_DEFAULT_MODEL) return input.model;
108140
const options = antigravityModelOptions(input.configOptions);
109-
return input.defaultModel && options.some((option) => option.value === input.defaultModel)
141+
return input.defaultModel &&
142+
(options.some((option) => option.value === input.defaultModel) ||
143+
splitLegacyAntigravityModel(input.configOptions, input.defaultModel) !== undefined)
110144
? input.defaultModel
111145
: current;
112146
}
@@ -116,7 +150,7 @@ export const applyAntigravityAcpModelSelection = Effect.fn("applyAntigravityAcpM
116150
function* <E>(input: {
117151
readonly runtime: Pick<
118152
AcpSessionRuntime.AcpSessionRuntime["Service"],
119-
"getConfigOptions" | "setModel"
153+
"getConfigOptions" | "setModel" | "setConfigOption"
120154
>;
121155
readonly model: string | null | undefined;
122156
readonly defaultModel?: string | undefined;
@@ -133,6 +167,16 @@ export const applyAntigravityAcpModelSelection = Effect.fn("applyAntigravityAcpM
133167
const explicit = Boolean(input.model) && input.model !== ANTIGRAVITY_DEFAULT_MODEL;
134168
if (resolved === undefined || (!explicit && resolved === current)) return current;
135169
const options = antigravityModelOptions(configOptions);
170+
const legacy = options.some((option) => option.value === resolved)
171+
? undefined
172+
: splitLegacyAntigravityModel(configOptions, resolved);
173+
if (legacy !== undefined) {
174+
yield* input.runtime.setModel(legacy.model).pipe(Effect.mapError(input.mapError));
175+
yield* input.runtime
176+
.setConfigOption(legacy.thinkingConfigId, legacy.thinkingLevel)
177+
.pipe(Effect.mapError(input.mapError));
178+
return legacy.model;
179+
}
136180
if (!options.some((option) => option.value === resolved)) {
137181
return yield* Effect.fail(
138182
input.mapError(

0 commit comments

Comments
 (0)