Skip to content
Open
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
59 changes: 57 additions & 2 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 @@ -295,12 +296,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<string>) =>
({
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 });
Expand Down
13 changes: 5 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,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),
},
];
});
Expand Down
Loading