From dcff454aebb838929e22b1eba4a30b74980175fe Mon Sep 17 00:00:00 2001 From: tensorcopy <10591164+tensorcopy@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:19:50 -0800 Subject: [PATCH 1/2] fix(server): keep per-model Antigravity thinking levels after restart Antigravity reports thinking levels only for the selected model. A model the server had not observed yet was given the selected model's levels (without a current value). Because that fallback was non-empty, the registry merge replaced the levels the model had reported earlier, so a model with more levels (for example xhigh) lost them after a restart. An unobserved model now reports no thinking descriptor, which lets the registry keep the levels it last reported. --- .../src/provider/AntigravityProvider.test.ts | 59 ++++++++++++++++++- .../src/provider/AntigravityProvider.ts | 13 ++-- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/apps/server/src/provider/AntigravityProvider.test.ts b/apps/server/src/provider/AntigravityProvider.test.ts index da518379487b2..58a6deebf2987 100644 --- a/apps/server/src/provider/AntigravityProvider.test.ts +++ b/apps/server/src/provider/AntigravityProvider.test.ts @@ -31,6 +31,7 @@ import { buildAntigravityModelsFromSession, makeAntigravityProvider, } from "./AntigravityProvider.ts"; +import { mergeProviderSnapshot } from "./ProviderRegistry.ts"; const decodeSettings = Schema.decodeSync(AntigravitySettings); const instanceId = ProviderInstanceId.make("antigravity-test"); @@ -287,12 +288,66 @@ describe("Antigravity model catalog", () => { expect(thinkingOf("gemini")).toMatchObject({ id: "thinking_level", currentValue: "high" }); expect(thinkingOf("claude")).toMatchObject({ id: "thinking_level", currentValue: "low" }); expect(thinkingOf("plain")).toBeUndefined(); - expect(thinkingOf("unseen")).toMatchObject({ id: "thinking_level" }); - expect(thinkingOf("unseen")).not.toHaveProperty("currentValue"); + expect(thinkingOf("unseen")).toBeUndefined(); }); }); it.layer(layerTest)("Antigravity provider snapshots", (it) => { + it.effect("keeps a model's reported thinking levels after a restart selects another model", () => + Effect.gen(function* () { + const levels = (currentValue: string, values: ReadonlyArray) => + ({ + id: "thinking_level", + name: "Thinking Level", + category: "thought_level", + type: "select", + currentValue, + options: values.map((value) => ({ value, name: value })), + }) satisfies EffectAcpSchema.SessionConfigOption; + const selecting = (model: string, thinking: EffectAcpSchema.SessionConfigOption) => ({ + ...started, + sessionSetupResult: { + ...sessionSetupResult, + configOptions: [ + { + ...modelConfig, + currentValue: model, + options: [ + { value: "deep", name: "Deep" }, + { value: "fast", name: "Fast" }, + ], + }, + thinking, + ], + }, + }); + const choicesOf = (provider: ServerProvider, slug: string) => + provider.models + .find((model) => model.slug === slug) + ?.capabilities?.optionDescriptors?.flatMap((descriptor) => + descriptor.type === "select" ? descriptor.options.map((option) => option.id) : [], + ); + + const before = yield* makeHarness(); + yield* before.initialize; + yield* before.provider.onSessionStarted( + selecting("deep", levels("low", ["low", "medium", "high", "xhigh"])), + ); + const published = yield* before.provider.snapshot.getSnapshot; + expect(choicesOf(published, "deep")).toEqual(["low", "medium", "high", "xhigh"]); + + // A restarted server has the published catalog but has observed no model yet. + const after = yield* makeHarness(); + yield* after.initialize; + yield* after.provider.onSessionStarted( + selecting("fast", levels("low", ["low", "medium", "high"])), + ); + const merged = mergeProviderSnapshot(published, yield* after.provider.snapshot.getSnapshot); + expect(choicesOf(merged, "fast")).toEqual(["low", "medium", "high"]); + expect(choicesOf(merged, "deep")).toEqual(["low", "medium", "high", "xhigh"]); + }), + ); + it.effect("does not probe or run helper safety checks while disabled", () => Effect.gen(function* () { const harness = yield* makeHarness({ enabled: false }); diff --git a/apps/server/src/provider/AntigravityProvider.ts b/apps/server/src/provider/AntigravityProvider.ts index 8e903d4224179..f14904f745746 100644 --- a/apps/server/src/provider/AntigravityProvider.ts +++ b/apps/server/src/provider/AntigravityProvider.ts @@ -63,14 +63,12 @@ type ThinkingConfig = NonNullable>; /** Thinking options each model reported when selected; `null` means it has none. */ export type AntigravityThinkingLevels = ReadonlyMap; -function thinkingCapabilities(config: ThinkingConfig | null | undefined, observed: boolean) { +function thinkingCapabilities(config: ThinkingConfig | null | undefined) { const descriptor = config ? acpProviderOptionDescriptors({ configOptions: [config], modeState: undefined })[0] : undefined; if (descriptor?.type !== "select") return EMPTY_MODEL_CAPABILITIES; - // Another model's selected level is not this model's default. - const { currentValue: _currentValue, ...unobserved } = descriptor; - return createModelCapabilities({ optionDescriptors: [observed ? descriptor : unobserved] }); + return createModelCapabilities({ optionDescriptors: [descriptor] }); } export function buildAntigravityModelsFromSession( @@ -111,10 +109,9 @@ export function buildAntigravityModelsFromSession( ...(entry.value === currentValue ? { isDefault: true, aliases: [ANTIGRAVITY_DEFAULT_MODEL] } : {}), - capabilities: - observed === undefined - ? thinkingCapabilities(currentThinking, false) - : thinkingCapabilities(observed, true), + // Levels differ per model, so an unobserved model reports none rather than the + // selected model's; the registry then keeps the levels it last reported. + capabilities: thinkingCapabilities(observed), }, ]; }); From 20c0467b0750a3c4537d2e58d8e535c34c96d471 Mon Sep 17 00:00:00 2001 From: tensorcopy <10591164+tensorcopy@users.noreply.github.com> Date: Mon, 23 Nov 2026 13:15:03 -0800 Subject: [PATCH 2/2] fix(server): clear stale Antigravity levels for non-thinking models An Antigravity model observed without thinking options reported empty capabilities, which the registry treated the same as an unobserved model and replaced with the levels from an older snapshot. Unobserved models now report null capabilities, which still inherit the last reported levels. A model observed without options reports explicit empty capabilities, and for Antigravity the registry no longer replaces them, so stale levels clear. Other providers keep the existing fallback. --- .../src/provider/AntigravityProvider.test.ts | 17 ++++++++++++++--- apps/server/src/provider/AntigravityProvider.ts | 6 +++--- apps/server/src/provider/ProviderRegistry.ts | 10 +++++++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/apps/server/src/provider/AntigravityProvider.test.ts b/apps/server/src/provider/AntigravityProvider.test.ts index 59e6fad44c966..3718591c574d5 100644 --- a/apps/server/src/provider/AntigravityProvider.test.ts +++ b/apps/server/src/provider/AntigravityProvider.test.ts @@ -296,7 +296,10 @@ describe("Antigravity model catalog", () => { expect(thinkingOf("gemini")).toMatchObject({ id: "thinking_level", currentValue: "high" }); expect(thinkingOf("claude")).toMatchObject({ id: "thinking_level", currentValue: "low" }); expect(thinkingOf("plain")).toBeUndefined(); - expect(thinkingOf("unseen")).toBeUndefined(); + const modelOf = (slug: string) => models.find((model) => model.slug === slug); + // An observed model without levels clears them; an unobserved one (null) leaves them to the registry. + expect(modelOf("plain")?.capabilities).toEqual({ optionDescriptors: [] }); + expect(modelOf("unseen")?.capabilities).toBeNull(); }); }); @@ -312,7 +315,7 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { currentValue, options: values.map((value) => ({ value, name: value })), }) satisfies EffectAcpSchema.SessionConfigOption; - const selecting = (model: string, thinking: EffectAcpSchema.SessionConfigOption) => ({ + const selecting = (model: string, thinking?: EffectAcpSchema.SessionConfigOption) => ({ ...started, sessionSetupResult: { ...sessionSetupResult, @@ -325,7 +328,7 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { { value: "fast", name: "Fast" }, ], }, - thinking, + ...(thinking ? [thinking] : []), ], }, }); @@ -353,6 +356,14 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { const merged = mergeProviderSnapshot(published, yield* after.provider.snapshot.getSnapshot); expect(choicesOf(merged, "fast")).toEqual(["low", "medium", "high"]); expect(choicesOf(merged, "deep")).toEqual(["low", "medium", "high", "xhigh"]); + + // A model observed without thinking options clears the levels it had before. + const plain = yield* makeHarness(); + yield* plain.initialize; + yield* plain.provider.onSessionStarted(selecting("fast")); + const cleared = mergeProviderSnapshot(merged, yield* plain.provider.snapshot.getSnapshot); + expect(choicesOf(cleared, "fast")).toEqual([]); + expect(choicesOf(cleared, "deep")).toEqual(["low", "medium", "high", "xhigh"]); }), ); diff --git a/apps/server/src/provider/AntigravityProvider.ts b/apps/server/src/provider/AntigravityProvider.ts index f946229079749..f73afb2837286 100644 --- a/apps/server/src/provider/AntigravityProvider.ts +++ b/apps/server/src/provider/AntigravityProvider.ts @@ -111,9 +111,9 @@ export function buildAntigravityModelsFromSession( ...(entry.value === currentValue ? { isDefault: true, aliases: [ANTIGRAVITY_DEFAULT_MODEL] } : {}), - // Levels differ per model, so an unobserved model reports none rather than the - // selected model's; the registry then keeps the levels it last reported. - capabilities: thinkingCapabilities(observed), + // Levels differ per model, so an unobserved model reports null rather than borrowing + // the selected model's; the registry then keeps the levels it last reported. + capabilities: observed === undefined ? null : thinkingCapabilities(observed), }, ]; }); diff --git a/apps/server/src/provider/ProviderRegistry.ts b/apps/server/src/provider/ProviderRegistry.ts index 43d66cd1ca049..9ab345abcf0b9 100644 --- a/apps/server/src/provider/ProviderRegistry.ts +++ b/apps/server/src/provider/ProviderRegistry.ts @@ -283,9 +283,17 @@ const mergeProviderModels = ( } const previousBySlug = new Map(previousModels.map((model) => [model.slug, model] as const)); + // Antigravity sends null capabilities for a model it has not observed, which inherits the + // previous levels, and explicit empty capabilities for one observed without options, which clears them. + const isAntigravity = provider.driver === ProviderDriverKind.make("antigravity"); const mergedModels = nextModels.map((model) => { const previousModel = previousBySlug.get(model.slug); - if (!previousModel || hasModelCapabilities(model) || !hasModelCapabilities(previousModel)) { + if ( + !previousModel || + hasModelCapabilities(model) || + !hasModelCapabilities(previousModel) || + (isAntigravity && model.capabilities !== null) + ) { return model; } return {