Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 66 additions & 3 deletions apps/server/src/provider/AntigravityProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
buildAntigravityModelsFromSession,
makeAntigravityProvider,
} from "./AntigravityProvider.ts";
import { mergeProviderSnapshot } from "./ProviderRegistry.ts";

const decodeSettings = Schema.decodeSync(AntigravitySettings);
const instanceId = ProviderInstanceId.make("antigravity-test");
Expand Down Expand Up @@ -255,7 +256,7 @@ describe("Antigravity model catalog", () => {
]);
});

it("offers each model the thinking levels it reported when selected", () => {
it("offers each model only the thinking levels it reported when selected", () => {
const thinking = (currentValue: string) =>
({
id: "thinking_level",
Expand Down Expand Up @@ -295,8 +296,70 @@ 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("keeps each model's probed thinking levels after a restart observes only the active model", () => {
const thinking = (levels: ReadonlyArray<string>) =>
({
id: "thinking_level",
name: "Thinking Level",
category: "thought_level",
type: "select",
currentValue: "low",
options: levels.map((value) => ({ value, name: value })),
}) satisfies EffectAcpSchema.SessionConfigOption;
const deep = thinking(["low", "medium", "high", "xhigh"]);
const models = {
...modelConfig,
currentValue: "neon",
options: [
{ value: "neon", name: "Neon" },
{ value: "carbon", name: "Carbon" },
{ value: "fixed", name: "Fixed effort" },
],
} satisfies EffectAcpSchema.SessionConfigOption;
const setup = { configOptions: [models, deep] };
const provider = {
instanceId,
driver,
status: "ready",
enabled: true,
installed: true,
version: null,
auth: { status: "authenticated" },
checkedAt: "2026-11-23T00:00:00.000Z",
slashCommands: [],
skills: [],
} as const;
// Sign-in or Refresh models walks every model, so each reports its own levels.
const probed = {
...provider,
models: buildAntigravityModelsFromSession(
setup,
new Map([
["carbon", thinking(["low", "medium", "high"])],
["fixed", null],
]),
),
} satisfies ServerProvider;
// After a restart the provider has observed only the session's model.
const restarted = {
...provider,
checkedAt: "2026-11-23T01:00:00.000Z",
models: buildAntigravityModelsFromSession(setup, new Map([["neon", deep]])),
} satisfies ServerProvider;

const merged = mergeProviderSnapshot(probed, restarted);
const levelsOf = (slug: string) => {
const descriptor = merged.models.find((model) => model.slug === slug)?.capabilities
?.optionDescriptors?.[0];
return descriptor?.type === "select" ? descriptor.options.map((option) => option.id) : [];
};

expect(levelsOf("neon")).toEqual(["low", "medium", "high", "xhigh"]);
expect(levelsOf("carbon")).toEqual(["low", "medium", "high"]);
expect(levelsOf("fixed")).toEqual([]);
});
});

Expand Down
12 changes: 4 additions & 8 deletions apps/server/src/provider/AntigravityProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ type ThinkingConfig = NonNullable<ReturnType<typeof antigravityThinkingConfig>>;
/** Thinking options each model reported when selected; `null` means it has none. */
export type AntigravityThinkingLevels = ReadonlyMap<string, ThinkingConfig | null>;

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(
Expand Down Expand Up @@ -113,10 +111,8 @@ 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; an unobserved model reports none so the registry keeps its cached ones.
capabilities: thinkingCapabilities(observed),
},
];
});
Expand Down
Loading