Skip to content

Commit 3c5d703

Browse files
t3dotggclaude
andcommitted
fix(antigravity): default new threads to Gemini 3.8 Flash
The catalog took Google's current model as the default, which is still Gemini 3.7 Flash (High). The model manifest now names a chat default for Antigravity and applyModelManifest moves the default flag and its alias to that model when the account offers it. The default alias resolves to the same model at session start, turn start, and in text generation helpers, and falls back to the agent's choice when the account lacks it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 1fba593 commit 3c5d703

9 files changed

Lines changed: 544 additions & 99 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,22 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
286286
}),
287287
),
288288
);
289+
const defaultModel = modelManifest.current.pipe(
290+
Effect.map((manifest) => ModelManifest.manifestDefaultModel(manifest, DRIVER)),
291+
);
289292
const adapter = yield* makeAntigravityAdapter(settings, {
290293
instanceId,
291294
makeRuntime,
292295
withProcess: authFlow.withProcess,
296+
defaultModel,
293297
onSessionStarted: provider.onSessionStarted,
294298
onAvailableCommands: provider.onAvailableCommands,
295299
onAuthRequired: provider.onAuthRequired,
296300
...(loggers.native ? { nativeEventLogger: loggers.native } : {}),
297301
});
298302
const textGeneration = yield* makeAntigravityTextGeneration({
299303
profileDirectory,
304+
defaultModel,
300305
withProcess: authFlow.withProcess,
301306
makeRuntime: (cwd) =>
302307
makeRuntime({

‎apps/server/src/provider/Layers/AntigravityAdapter.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {
6767
applyAntigravityAcpModelSelection,
6868
buildAntigravityPrompt,
6969
type AntigravityAcpRuntimeInput,
70+
resolveAntigravityModel,
7071
} from "../acp/AntigravityAcpSupport.ts";
7172
import {
7273
antigravityApprovalOptions,
@@ -133,6 +134,8 @@ export interface AntigravityAdapterOptions {
133134
cwd: string,
134135
) => Effect.Effect<void>;
135136
readonly onAuthRequired?: Effect.Effect<void>;
137+
/** Model the provider default alias selects, when the account offers it. */
138+
readonly defaultModel?: Effect.Effect<string | undefined>;
136139
readonly nativeEventLogger?: EventNdjsonLogger;
137140
}
138141

@@ -706,6 +709,7 @@ export const makeAntigravityAdapter = Effect.fn("makeAntigravityAdapter")(functi
706709
const model = yield* applyAntigravityAcpModelSelection({
707710
runtime,
708711
model: input.modelSelection?.model,
712+
defaultModel: yield* options.defaultModel ?? Effect.succeed(undefined),
709713
mapError: (cause) => cause,
710714
});
711715
yield* runtime.setMode(antigravityPermissionMode(input.runtimeMode));
@@ -883,13 +887,11 @@ export const makeAntigravityAdapter = Effect.fn("makeAntigravityAdapter")(functi
883887
yield* requireSession(input.threadId);
884888
const requestedModel = input.modelSelection?.model ?? context.session.model;
885889
const configOptions = yield* context.runtime.getConfigOptions;
886-
const currentModel = configOptions.find((option) => option.id === "model");
887-
const model =
888-
requestedModel === ANTIGRAVITY_DEFAULT_MODEL
889-
? currentModel?.type === "select"
890-
? currentModel.currentValue
891-
: undefined
892-
: requestedModel;
890+
const model = resolveAntigravityModel({
891+
configOptions,
892+
model: requestedModel,
893+
defaultModel: yield* options.defaultModel ?? Effect.succeed(undefined),
894+
});
893895
const availableModels = antigravityModelOptions(configOptions);
894896
if (model && !availableModels.some((option) => option.value === model)) {
895897
return yield* EffectAcpErrors.AcpRequestError.invalidParams(

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { HttpClient, HttpClientResponse } from "effect/unstable/http";
99
import * as ServerConfig from "../config.ts";
1010
import * as ServerSettings from "../serverSettings.ts";
1111
import {
12+
applyManifestDefault,
1213
BUNDLED_MODEL_MANIFEST,
1314
classifyModels,
1415
make,
@@ -59,6 +60,36 @@ describe("classifyModels", () => {
5960
});
6061
});
6162

63+
describe("applyManifestDefault", () => {
64+
it("moves the default flag and its aliases to the manifest's chat default", () => {
65+
const driver = ProviderDriverKind.make("antigravity");
66+
const manifest: ModelManifestData = {
67+
version: 1,
68+
currentModels: {},
69+
providers: {
70+
antigravity: {
71+
defaults: { chat: "gemini-new" },
72+
profiles: {},
73+
models: [{ slug: "gemini-new", name: "New", status: "current" }],
74+
},
75+
},
76+
};
77+
const models = [
78+
model({ slug: "gemini-old", isDefault: true, aliases: ["antigravity-default"] }),
79+
model({ slug: "gemini-new" }),
80+
];
81+
assert.deepStrictEqual(applyManifestDefault(models, manifest, driver), [
82+
model({ slug: "gemini-old" }),
83+
model({ slug: "gemini-new", isDefault: true, aliases: ["antigravity-default"] }),
84+
]);
85+
// The account does not offer the manifest default: keep the runtime's choice.
86+
assert.deepStrictEqual(
87+
applyManifestDefault(models.slice(0, 1), manifest, driver),
88+
models.slice(0, 1),
89+
);
90+
});
91+
});
92+
6293
describe("resolveProviderCatalog", () => {
6394
it("resolves generic model presentation through a reusable profile", () => {
6495
const manifest: ModelManifestData = {

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,52 @@ export function applyModelManifest(
216216
manifest: ModelManifestData,
217217
driverKind: ProviderDriverKind,
218218
): ServerProviderDraft {
219-
return { ...draft, models: classifyModels(draft.models, manifest, driverKind) };
219+
return {
220+
...draft,
221+
models: applyManifestDefault(
222+
classifyModels(draft.models, manifest, driverKind),
223+
manifest,
224+
driverKind,
225+
),
226+
};
227+
}
228+
229+
/** The manifest's chat default for `driverKind`, when it names one. */
230+
export function manifestDefaultModel(
231+
manifest: ModelManifestData,
232+
driverKind: ProviderDriverKind,
233+
): string | undefined {
234+
return manifest.providers?.[driverKind]?.defaults?.chat;
235+
}
236+
237+
/**
238+
* Moves `isDefault` to the manifest's chat default when the catalog carries
239+
* it. Providers that learn their default from the runtime (Antigravity takes
240+
* Google's current model) can be overridden here without a release. Aliases
241+
* that pointed at the old default move with the flag so the shared
242+
* "provider default" alias keeps resolving.
243+
*/
244+
export function applyManifestDefault(
245+
models: ReadonlyArray<ServerProviderModel>,
246+
manifest: ModelManifestData,
247+
driverKind: ProviderDriverKind,
248+
): ReadonlyArray<ServerProviderModel> {
249+
const slug = manifestDefaultModel(manifest, driverKind);
250+
if (slug === undefined || !models.some((model) => model.slug === slug)) return models;
251+
const previous = models.find((model) => model.isDefault && model.slug !== slug);
252+
if (!previous) return models;
253+
const movedAliases = previous.aliases ?? [];
254+
return models.map((model) => {
255+
if (model.slug === previous.slug) {
256+
const { isDefault: _isDefault, aliases: _aliases, ...rest } = model;
257+
return rest;
258+
}
259+
if (model.slug === slug) {
260+
const aliases = [...new Set([...(model.aliases ?? []), ...movedAliases])];
261+
return { ...model, isDefault: true, ...(aliases.length > 0 ? { aliases } : {}) };
262+
}
263+
return model;
264+
});
220265
}
221266

222267
/** Model-level half of `applyModelManifest`, exported for focused tests. */

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,30 @@ describe("applyAntigravityAcpModelSelection", () => {
9494
}),
9595
);
9696

97+
it.effect("selects the manifest default for the alias when the account offers it", () =>
98+
Effect.gen(function* () {
99+
const { runtime, selections } = makeModelRuntime();
100+
const model = yield* applyAntigravityAcpModelSelection({
101+
runtime,
102+
model: ANTIGRAVITY_DEFAULT_MODEL,
103+
defaultModel: "gemini-saved",
104+
mapError: (cause) => cause,
105+
});
106+
expect(model).toBe("gemini-saved");
107+
expect(selections).toEqual(["gemini-saved"]);
108+
109+
const { runtime: other, selections: otherSelections } = makeModelRuntime();
110+
const fallback = yield* applyAntigravityAcpModelSelection({
111+
runtime: other,
112+
model: ANTIGRAVITY_DEFAULT_MODEL,
113+
defaultModel: "gemini-not-offered",
114+
mapError: (cause) => cause,
115+
});
116+
expect(fallback).toBe("gemini-default");
117+
expect(otherSelections).toEqual([]);
118+
}),
119+
);
120+
97121
it.effect.each(["gemini-removed", "Gemini saved", "gemini-saved[reasoning=high]"])(
98122
"rejects unavailable or non-native model ID %s without selecting a fallback",
99123
(model) =>

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

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ export function antigravityModelOptions(
104104
return model.options.flatMap((entry) => ("value" in entry ? [entry] : entry.options));
105105
}
106106

107+
/**
108+
* Resolves the model a turn should run on. A saved selection is reapplied
109+
* as-is. The provider default alias resolves to `defaultModel` when the
110+
* account offers it, so T3 can pick a newer model than the one Google marks
111+
* current. Otherwise the agent's current selection stands.
112+
*/
113+
export function resolveAntigravityModel(input: {
114+
readonly configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
115+
readonly model: string | null | undefined;
116+
readonly defaultModel?: string | undefined;
117+
}): string | undefined {
118+
const modelConfig = input.configOptions.find((option) => option.id === "model");
119+
const current = modelConfig?.type === "select" ? modelConfig.currentValue : undefined;
120+
if (input.model && input.model !== ANTIGRAVITY_DEFAULT_MODEL) return input.model;
121+
const options = antigravityModelOptions(input.configOptions);
122+
return input.defaultModel && options.some((option) => option.value === input.defaultModel)
123+
? input.defaultModel
124+
: current;
125+
}
126+
107127
/** Never replace a saved selection with the default returned by a cold resume. */
108128
export const applyAntigravityAcpModelSelection = Effect.fn("applyAntigravityAcpModelSelection")(
109129
function* <E>(input: {
@@ -112,25 +132,35 @@ export const applyAntigravityAcpModelSelection = Effect.fn("applyAntigravityAcpM
112132
"getConfigOptions" | "setModel"
113133
>;
114134
readonly model: string | null | undefined;
135+
/** Model to select for the provider default alias. See `resolveAntigravityModel`. */
136+
readonly defaultModel?: string | undefined;
115137
readonly mapError: (cause: EffectAcpErrors.AcpError) => E;
116138
}): Effect.fn.Return<string | undefined, E> {
117139
const configOptions = yield* input.runtime.getConfigOptions;
118140
const modelConfig = configOptions.find((option) => option.id === "model");
119-
if (!input.model || input.model === ANTIGRAVITY_DEFAULT_MODEL) {
120-
return modelConfig?.type === "select" ? modelConfig.currentValue : undefined;
121-
}
141+
const current = modelConfig?.type === "select" ? modelConfig.currentValue : undefined;
142+
const resolved = resolveAntigravityModel({
143+
configOptions,
144+
model: input.model,
145+
defaultModel: input.defaultModel,
146+
});
147+
// The default alias never sends an internal ID. It selects the manifest
148+
// default when that differs from the agent's current model, and otherwise
149+
// leaves the agent's choice alone.
150+
const explicit = Boolean(input.model) && input.model !== ANTIGRAVITY_DEFAULT_MODEL;
151+
if (resolved === undefined || (!explicit && resolved === current)) return current;
122152
const options = antigravityModelOptions(configOptions);
123-
if (!options.some((option) => option.value === input.model)) {
153+
if (!options.some((option) => option.value === resolved)) {
124154
return yield* Effect.fail(
125155
input.mapError(
126156
EffectAcpErrors.AcpRequestError.invalidParams(
127-
`Antigravity model '${input.model}' is unavailable for this Google account. Select an available model.`,
157+
`Antigravity model '${resolved}' is unavailable for this Google account. Select an available model.`,
128158
),
129159
),
130160
);
131161
}
132-
yield* input.runtime.setModel(input.model).pipe(Effect.mapError(input.mapError));
133-
return input.model;
162+
yield* input.runtime.setModel(resolved).pipe(Effect.mapError(input.mapError));
163+
return resolved;
134164
},
135165
);
136166

0 commit comments

Comments
 (0)