From 293084165a3d63183618ccffced44e78ab5f4885 Mon Sep 17 00:00:00 2001 From: Simone <185146821+Lucenx9@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:28:53 +0100 Subject: [PATCH 1/2] fix(antigravity): honor the saved thinking level in text generation --- .../AntigravityTextGeneration.test.ts | 116 ++++++++++++++---- .../AntigravityTextGeneration.ts | 29 ++++- 2 files changed, 122 insertions(+), 23 deletions(-) diff --git a/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts b/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts index 5a410dbf342f7..6e524bcb9bbca 100644 --- a/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts +++ b/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts @@ -62,6 +62,8 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* readonly rejectAdmission?: boolean; readonly sessionId?: string; readonly startupSkills?: boolean; + readonly initialModel?: string; + readonly rejectThinkingUpdate?: boolean; } = {}, ) { const fs = yield* FileSystem.FileSystem; @@ -84,6 +86,8 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* prompts: [] as Array[0]>, selectedModels: [] as Array, selectedModes: [] as Array, + promptThinkingLevels: [] as Array, + thinkingUpdates: [] as Array, nativeFilesAtClose: [] as Array, cancellations: 0, stop: undefined as Effect.Effect | undefined, @@ -132,6 +136,8 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* }), ); let sessionUpdate: Parameters[0] = () => Effect.void; + let currentModel = options.initialModel ?? modelSelection.model; + let thinkingLevel = "high"; return { start: () => @@ -164,25 +170,58 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function* state.selectedModes.push(mode); return {}; }), - getConfigOptions: Effect.succeed([ - { - id: "model", - name: "Model", - category: "model", - type: "select", - currentValue: modelSelection.model, - options: [{ value: modelSelection.model, name: "Gemini test" }], - }, - ]), + getConfigOptions: Effect.sync(() => { + const config: Array = [ + { + id: "model", + name: "Model", + category: "model", + type: "select", + currentValue: currentModel, + options: [ + { value: modelSelection.model, name: "Gemini test" }, + { value: "gemini-native-default", name: "Gemini native default" }, + ], + }, + ]; + if (currentModel === modelSelection.model) { + config.push({ + id: "thinking_level", + name: "Thinking level", + category: "thought_level", + type: "select", + currentValue: thinkingLevel, + options: [ + { value: "low", name: "Low" }, + { value: "high", name: "High" }, + ], + }); + } + return config; + }), getEvents: () => Stream.fromQueue(events), setModel: (model) => Effect.sync(() => { state.selectedModels.push(model); + currentModel = model; + }), + setConfigOption: (id, value) => + Effect.gen(function* () { + if (id === "thinking_level" && typeof value === "string") { + state.thinkingUpdates.push(value); + if (options.rejectThinkingUpdate) { + return yield* AcpRequestError.invalidParams( + "Thinking level is no longer available.", + ); + } + thinkingLevel = value; + } + return { configOptions: [] }; }), - setConfigOption: () => Effect.succeed({ configOptions: [] }), prompt: (request) => Effect.gen(function* () { state.prompts.push(request); + state.promptThinkingLevels.push(thinkingLevel); yield* Deferred.succeed(enteredPrompt, undefined); const emit: PromptContext["emit"] = (update, sessionId = nativeSessionId) => sessionUpdate({ sessionId, update }); @@ -520,17 +559,50 @@ it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => { }), ); - it.effect("uses the native default without sending T3's default selection as a model ID", () => - Effect.gen(function* () { - const fixture = yield* makeFixture(); - const result = yield* fixture.textGeneration.generateThreadTitle({ - ...fixture.titleInput, - modelSelection: { ...modelSelection, model: ANTIGRAVITY_DEFAULT_MODEL }, - }); - expect(result).toEqual({ title: "Repair login" }); - expect(fixture.state.selectedModels).toEqual([]); - yield* fixture.assertCleaned; - }), + it.effect.each([ + { name: "native default", selected: undefined, expected: "high", updates: [] }, + { + name: "after switching models", + selected: "low", + expected: "low", + updates: ["low"], + initialModel: "gemini-native-default", + }, + { name: "when already current", selected: "high", expected: "high", updates: [] }, + { name: "when not advertised", selected: "medium", expected: "high", updates: [] }, + { + name: "when rejected", + selected: "low", + expected: "high", + updates: ["low"], + rejectThinkingUpdate: true, + }, + ])( + "generates a title with the thinking level $name", + ({ selected, expected, updates, initialModel, rejectThinkingUpdate }) => + Effect.gen(function* () { + const fixture = yield* makeFixture({ + initialModel: initialModel ?? modelSelection.model, + rejectThinkingUpdate: rejectThinkingUpdate === true, + }); + const result = yield* fixture.textGeneration.generateThreadTitle({ + ...fixture.titleInput, + modelSelection: { + ...modelSelection, + model: initialModel === undefined ? ANTIGRAVITY_DEFAULT_MODEL : modelSelection.model, + ...(selected === undefined + ? {} + : { options: [{ id: "thinking_level", value: selected }] }), + }, + }); + expect(result).toEqual({ title: "Repair login" }); + expect(fixture.state.selectedModels).toEqual( + initialModel === undefined ? [] : [modelSelection.model], + ); + expect(fixture.state.thinkingUpdates).toEqual(updates); + expect(fixture.state.promptThinkingLevels).toEqual([expected]); + yield* fixture.assertCleaned; + }), ); it.effect.each([ diff --git a/apps/server/src/textGeneration/AntigravityTextGeneration.ts b/apps/server/src/textGeneration/AntigravityTextGeneration.ts index b67bad85faf03..364a97f3bd53d 100644 --- a/apps/server/src/textGeneration/AntigravityTextGeneration.ts +++ b/apps/server/src/textGeneration/AntigravityTextGeneration.ts @@ -11,13 +11,17 @@ import * as Scope from "effect/Scope"; import * as Stream from "effect/Stream"; import { type AcpError, AcpRequestError } from "effect-acp/errors"; -import { applyAntigravityAcpModelSelection } from "../provider/acp/AntigravityAcpSupport.ts"; +import { + antigravityThinkingConfig, + applyAntigravityAcpModelSelection, +} from "../provider/acp/AntigravityAcpSupport.ts"; import { removeAntigravitySessionFiles } from "../provider/acp/AntigravitySessionFiles.ts"; import { ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE, isAntigravitySignInRequiredError, } from "../provider/antigravityAuthSupport.ts"; import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; +import { collectSessionConfigOptionValues } from "@t3tools/provider-acp/server/runtimeModel"; import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations"; const ANTIGRAVITY_TIMEOUT_MS = 180_000; @@ -260,6 +264,29 @@ export const makeAntigravityTextGeneration = Effect.fn("makeAntigravityTextGener cause, }), }); + const savedOptions = input.modelSelection.options; + if (savedOptions?.length) { + const thinking = antigravityThinkingConfig(yield* runtime.getConfigOptions); + const selected = savedOptions.find((option) => option.id === thinking?.id)?.value; + if ( + thinking !== undefined && + typeof selected === "string" && + selected !== thinking.currentValue && + collectSessionConfigOptionValues(thinking).includes(selected) + ) { + yield* runtime.setConfigOption(thinking.id, selected).pipe( + Effect.catchTags({ + AcpRequestError: (error) => + error.code === -32602 + ? Effect.logDebug("Antigravity rejected the saved thinking level", { + optionId: thinking.id, + value: selected, + }) + : Effect.fail(error), + }), + ); + } + } const result = yield* runtime.prompt({ prompt: [ From 5ab7c0431c3ed1e95d3a6952858a8b97244c6acc Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 13:55:19 +0000 Subject: [PATCH 2/2] test(antigravity): drop the redundant already-current thinking case Co-Authored-By: Claude Opus 5.5 --- apps/server/src/textGeneration/AntigravityTextGeneration.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts b/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts index 6e524bcb9bbca..d8164ac30d4e5 100644 --- a/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts +++ b/apps/server/src/textGeneration/AntigravityTextGeneration.test.ts @@ -568,7 +568,6 @@ it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => { updates: ["low"], initialModel: "gemini-native-default", }, - { name: "when already current", selected: "high", expected: "high", updates: [] }, { name: "when not advertised", selected: "medium", expected: "high", updates: [] }, { name: "when rejected",