@devries-cameron20 / t3code Mirror · read-only / commits / e74b795535
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

fix(antigravity): honor the saved thinking level in text generation (#39720)

Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Simone committed Nov 20, 2026 at 15:21 UTC e74b795535162645a4abd2cc7600899387b59ec9
2 files changed +121 -23
apps/server/src/textGeneration/AntigravityTextGeneration.test.ts
+93 -22
@@ -62,6 +62,8 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function*
62 readonly rejectAdmission?: boolean;
63 readonly sessionId?: string;
64 readonly startupSkills?: boolean;
65 + readonly initialModel?: string;
66 + readonly rejectThinkingUpdate?: boolean;
67 } = {},
68 ) {
69 const fs = yield* FileSystem.FileSystem;
@@ -84,6 +86,8 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function*
86 prompts: [] as Array<Parameters<TextRuntime["prompt"]>[0]>,
87 selectedModels: [] as Array<string>,
88 selectedModes: [] as Array<string>,
89 + promptThinkingLevels: [] as Array<string>,
90 + thinkingUpdates: [] as Array<string>,
91 nativeFilesAtClose: [] as Array<boolean>,
92 cancellations: 0,
93 stop: undefined as Effect.Effect<void> | undefined,
@@ -132,6 +136,8 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function*
136 }),
137 );
138 let sessionUpdate: Parameters<TextRuntime["handleSessionUpdate"]>[0] = () => Effect.void;
139 + let currentModel = options.initialModel ?? modelSelection.model;
140 + let thinkingLevel = "high";
141
142 return {
143 start: () =>
@@ -164,25 +170,58 @@ const makeFixture = Effect.fn("makeAntigravityTextGenerationFixture")(function*
170 state.selectedModes.push(mode);
171 return {};
172 }),
167 - getConfigOptions: Effect.succeed([
168 - {
169 - id: "model",
170 - name: "Model",
171 - category: "model",
172 - type: "select",
173 - currentValue: modelSelection.model,
174 - options: [{ value: modelSelection.model, name: "Gemini test" }],
175 - },
176 - ]),
173 + getConfigOptions: Effect.sync(() => {
174 + const config: Array<AcpSchema.SessionConfigOption> = [
175 + {
176 + id: "model",
177 + name: "Model",
178 + category: "model",
179 + type: "select",
180 + currentValue: currentModel,
181 + options: [
182 + { value: modelSelection.model, name: "Gemini test" },
183 + { value: "gemini-native-default", name: "Gemini native default" },
184 + ],
185 + },
186 + ];
187 + if (currentModel === modelSelection.model) {
188 + config.push({
189 + id: "thinking_level",
190 + name: "Thinking level",
191 + category: "thought_level",
192 + type: "select",
193 + currentValue: thinkingLevel,
194 + options: [
195 + { value: "low", name: "Low" },
196 + { value: "high", name: "High" },
197 + ],
198 + });
199 + }
200 + return config;
201 + }),
202 getEvents: () => Stream.fromQueue(events),
203 setModel: (model) =>
204 Effect.sync(() => {
205 state.selectedModels.push(model);
206 + currentModel = model;
207 + }),
208 + setConfigOption: (id, value) =>
209 + Effect.gen(function* () {
210 + if (id === "thinking_level" && typeof value === "string") {
211 + state.thinkingUpdates.push(value);
212 + if (options.rejectThinkingUpdate) {
213 + return yield* AcpRequestError.invalidParams(
214 + "Thinking level is no longer available.",
215 + );
216 + }
217 + thinkingLevel = value;
218 + }
219 + return { configOptions: [] };
220 }),
182 - setConfigOption: () => Effect.succeed({ configOptions: [] }),
221 prompt: (request) =>
222 Effect.gen(function* () {
223 state.prompts.push(request);
224 + state.promptThinkingLevels.push(thinkingLevel);
225 yield* Deferred.succeed(enteredPrompt, undefined);
226 const emit: PromptContext["emit"] = (update, sessionId = nativeSessionId) =>
227 sessionUpdate({ sessionId, update });
@@ -520,17 +559,49 @@ it.layer(NodeServices.layer)("AntigravityTextGeneration", (it) => {
559 }),
560 );
561
523 - it.effect("uses the native default without sending T3's default selection as a model ID", () =>
524 - Effect.gen(function* () {
525 - const fixture = yield* makeFixture();
526 - const result = yield* fixture.textGeneration.generateThreadTitle({
527 - ...fixture.titleInput,
528 - modelSelection: { ...modelSelection, model: ANTIGRAVITY_DEFAULT_MODEL },
529 - });
530 - expect(result).toEqual({ title: "Repair login" });
531 - expect(fixture.state.selectedModels).toEqual([]);
532 - yield* fixture.assertCleaned;
533 - }),
562 + it.effect.each([
563 + { name: "native default", selected: undefined, expected: "high", updates: [] },
564 + {
565 + name: "after switching models",
566 + selected: "low",
567 + expected: "low",
568 + updates: ["low"],
569 + initialModel: "gemini-native-default",
570 + },
571 + { name: "when not advertised", selected: "medium", expected: "high", updates: [] },
572 + {
573 + name: "when rejected",
574 + selected: "low",
575 + expected: "high",
576 + updates: ["low"],
577 + rejectThinkingUpdate: true,
578 + },
579 + ])(
580 + "generates a title with the thinking level $name",
581 + ({ selected, expected, updates, initialModel, rejectThinkingUpdate }) =>
582 + Effect.gen(function* () {
583 + const fixture = yield* makeFixture({
584 + initialModel: initialModel ?? modelSelection.model,
585 + rejectThinkingUpdate: rejectThinkingUpdate === true,
586 + });
587 + const result = yield* fixture.textGeneration.generateThreadTitle({
588 + ...fixture.titleInput,
589 + modelSelection: {
590 + ...modelSelection,
591 + model: initialModel === undefined ? ANTIGRAVITY_DEFAULT_MODEL : modelSelection.model,
592 + ...(selected === undefined
593 + ? {}
594 + : { options: [{ id: "thinking_level", value: selected }] }),
595 + },
596 + });
597 + expect(result).toEqual({ title: "Repair login" });
598 + expect(fixture.state.selectedModels).toEqual(
599 + initialModel === undefined ? [] : [modelSelection.model],
600 + );
601 + expect(fixture.state.thinkingUpdates).toEqual(updates);
602 + expect(fixture.state.promptThinkingLevels).toEqual([expected]);
603 + yield* fixture.assertCleaned;
604 + }),
605 );
606
607 it.effect.each([
apps/server/src/textGeneration/AntigravityTextGeneration.ts
+28 -1
@@ -11,13 +11,17 @@ import * as Scope from "effect/Scope";
11 import * as Stream from "effect/Stream";
12 import { type AcpError, AcpRequestError } from "effect-acp/errors";
13
14 -import { applyAntigravityAcpModelSelection } from "../provider/acp/AntigravityAcpSupport.ts";
14 +import {
15 + antigravityThinkingConfig,
16 + applyAntigravityAcpModelSelection,
17 +} from "../provider/acp/AntigravityAcpSupport.ts";
18 import { removeAntigravitySessionFiles } from "../provider/acp/AntigravitySessionFiles.ts";
19 import {
20 ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE,
21 isAntigravitySignInRequiredError,
22 } from "../provider/antigravityAuthSupport.ts";
23 import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
24 +import { collectSessionConfigOptionValues } from "@t3tools/provider-acp/server/runtimeModel";
25 import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations";
26
27 const ANTIGRAVITY_TIMEOUT_MS = 180_000;
@@ -260,6 +264,29 @@ export const makeAntigravityTextGeneration = Effect.fn("makeAntigravityTextGener
264 cause,
265 }),
266 });
267 + const savedOptions = input.modelSelection.options;
268 + if (savedOptions?.length) {
269 + const thinking = antigravityThinkingConfig(yield* runtime.getConfigOptions);
270 + const selected = savedOptions.find((option) => option.id === thinking?.id)?.value;
271 + if (
272 + thinking !== undefined &&
273 + typeof selected === "string" &&
274 + selected !== thinking.currentValue &&
275 + collectSessionConfigOptionValues(thinking).includes(selected)
276 + ) {
277 + yield* runtime.setConfigOption(thinking.id, selected).pipe(
278 + Effect.catchTags({
279 + AcpRequestError: (error) =>
280 + error.code === -32602
281 + ? Effect.logDebug("Antigravity rejected the saved thinking level", {
282 + optionId: thinking.id,
283 + value: selected,
284 + })
285 + : Effect.fail(error),
286 + }),
287 + );
288 + }
289 + }
290
291 const result = yield* runtime.prompt({
292 prompt: [