GeezerVison is showing github.com — fix(antigravity): restore concrete ACP model selection · pauljones0/t3code@86d7df9
File treeExpand file treeCollapse file tree Open diff view settings orchestration-v2/Adapters
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts +161-37Lines changed: 161 additions & 37 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import * as NodeServices from "@effect/platform-node/NodeServices"; | 2 | 2 | import { assert, describe, it } from "@effect/vitest"; | 3 | 3 | import { | | 4 | + ANTIGRAVITY_DEFAULT_MODEL, | 4 | 5 | MessageId, | 5 | 6 | NodeId, | 6 | 7 | ProjectId, | @@ -15,6 +16,8 @@ import * as Crypto from "effect/Crypto"; | 15 | 16 | import * as DateTime from "effect/DateTime"; | 16 | 17 | import * as Effect from "effect/Effect"; | 17 | 18 | import * as Exit from "effect/Exit"; | | 19 | +import * as Fiber from "effect/Fiber"; | | 20 | +import * as Scope from "effect/Scope"; | 18 | 21 | import * as FileSystem from "effect/FileSystem"; | 19 | 22 | import * as Layer from "effect/Layer"; | 20 | 23 | import * as Path from "effect/Path"; | @@ -25,9 +28,12 @@ import type * as EffectAcpSchema from "effect-acp/compat"; | 25 | 28 | import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; | 26 | 29 | import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions"; | 27 | 30 | import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost"; | 28 | | -import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; | | 31 | +import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; | 29 | 32 | import { makeAntigravityAcpRuntime } from "../../provider/acp/AntigravityAcpSupport.ts"; | 30 | | -import { antigravity140Session } from "../../provider/acp/antigravity140.fixture.ts"; | | 33 | +import { | | 34 | + antigravity140AgentSource, | | 35 | + decodeAntigravity140Request, | | 36 | +} from "../../provider/acp/antigravity140.fixture.ts"; | 31 | 37 | import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; | 32 | 38 | import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter"; | 33 | 39 | import { | @@ -59,41 +65,6 @@ function permissionRequest( | 59 | 65 | } | 60 | 66 |
| 61 | 67 | describe("AntigravityAdapterV2 flavor", () => { | 62 | | - it.effect("restores an ACP 1.4 concrete model instead of selecting the family", () => { | 63 | | - const selected: string[] = []; | 64 | | - return Effect.gen(function* () { | 65 | | - const runtime = yield* AcpSessionRuntime.AcpSessionRuntime; | 66 | | - const model = yield* flavor.applyModelSelection!({ | 67 | | - runtime, | 68 | | - startResult: { | 69 | | - sessionId: antigravity140Session.sessionId, | 70 | | - sessionSetupResult: antigravity140Session, | 71 | | - initializeResult: { protocolVersion: 1 }, | 72 | | - modelConfigId: "model", | 73 | | - }, | 74 | | - modelSelection: { | 75 | | - instanceId: ProviderInstanceId.make("antigravity-test"), | 76 | | - model: "gemini-3.8-flash-low", | 77 | | - }, | 78 | | - }); | 79 | | - assert.equal(model, "gemini-3.8-flash-low"); | 80 | | - assert.deepEqual(selected, ["gemini-3.8-flash-low"]); | 81 | | - }).pipe( | 82 | | - Effect.provide( | 83 | | - Layer.mock(AcpSessionRuntime.AcpSessionRuntime)({ | 84 | | - processContainment: "none", | 85 | | - getConfigOptions: Effect.succeed(antigravity140Session.configOptions), | 86 | | - setModel: () => Effect.die("The model config only accepts a family ID"), | 87 | | - setSessionModel: (model) => | 88 | | - Effect.sync(() => { | 89 | | - selected.push(model); | 90 | | - return {}; | 91 | | - }), | 92 | | - }), | 93 | | - ), | 94 | | - ); | 95 | | - }); | 96 | | - | 97 | 68 | it("keeps a successful subagent launch running until the parent turn becomes idle", () => { | 98 | 69 | const batch = flavor.extractSubagentUpdate?.({ | 99 | 70 | toolCallId: "trajectory:4", | @@ -170,6 +141,159 @@ const layerSession = Layer.mergeAll( | 170 | 141 | TestProviderHost.layer().pipe(Layer.provide(NodeServices.layer)), | 171 | 142 | ); | 172 | 143 |
| | 144 | +describe("AntigravityAdapterV2 ACP 1.4 models", () => { | | 145 | + it.effect( | | 146 | + "uses concrete models for fresh and resumed chat and restores the default after thinking changes", | | 147 | + () => | | 148 | + Effect.gen(function* () { | | 149 | + const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; | | 150 | + const fileSystem = yield* FileSystem.FileSystem; | | 151 | + const path = yield* Path.Path; | | 152 | + const crypto = yield* Crypto.Crypto; | | 153 | + const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-ag-models-" }); | | 154 | + const agentPath = path.join(workspace, "agent.mjs"); | | 155 | + const logPath = path.join(workspace, "requests.ndjson"); | | 156 | + yield* fileSystem.writeFileString(agentPath, antigravity140AgentSource); | | 157 | + const instanceId = ProviderInstanceId.make("antigravity-model-test"); | | 158 | + const adapter = yield* makeAntigravityAdapterV2({ | | 159 | + instanceId, | | 160 | + selfInvocation: yield* resolveSelfInvocation(), | | 161 | + makeRuntime: (input) => | | 162 | + makeAntigravityAcpRuntime({ | | 163 | + ...input, | | 164 | + childProcessSpawner, | | 165 | + spawn: { | | 166 | + command: process.execPath, | | 167 | + args: [agentPath], | | 168 | + cwd: workspace, | | 169 | + env: { T3_ACP_REQUEST_LOG_PATH: logPath }, | | 170 | + }, | | 171 | + }).pipe(Effect.provideService(Crypto.Crypto, crypto)), | | 172 | + withProcess: (_stop, task) => task, | | 173 | + defaultModel: Effect.succeed("gemini-3.8-flash-high"), | | 174 | + }); | | 175 | + const threadId = ThreadId.make("thread-antigravity-models"); | | 176 | + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({ | | 177 | + runtimeMode: "full-access", | | 178 | + interactionMode: "default", | | 179 | + cwd: workspace, | | 180 | + }); | | 181 | + const savedModel = { instanceId, model: "gemini-3.8-flash-low" }; | | 182 | + const open = { | | 183 | + threadId, | | 184 | + providerSessionId: ProviderSessionId.make("provider-session-antigravity-models"), | | 185 | + modelSelection: savedModel, | | 186 | + runtimePolicy, | | 187 | + }; | | 188 | + const freshScope = yield* Scope.fork(yield* Effect.scope); | | 189 | + let session = yield* adapter | | 190 | + .openSession(open) | | 191 | + .pipe(Effect.provideService(Scope.Scope, freshScope)); | | 192 | + const providerThread = yield* session.ensureThread(open); | | 193 | + const now = yield* DateTime.now; | | 194 | + const turn = Effect.fnUntraced(function* ( | | 195 | + ordinal: number, | | 196 | + modelSelection: typeof savedModel & { options?: Array<{ id: string; value: string }> }, | | 197 | + ) { | | 198 | + const completed = yield* session.events.pipe( | | 199 | + Stream.takeUntil( | | 200 | + (event) => | | 201 | + event.type === "provider_turn.updated" && event.providerTurn.status === "completed", | | 202 | + ), | | 203 | + Stream.runCollect, | | 204 | + Effect.forkChild, | | 205 | + ); | | 206 | + yield* session.startTurn({ | | 207 | + appThread: { | | 208 | + createdBy: "user", | | 209 | + creationSource: "web", | | 210 | + id: threadId, | | 211 | + projectId: ProjectId.make("project-antigravity-models"), | | 212 | + title: "Antigravity models", | | 213 | + providerInstanceId: instanceId, | | 214 | + modelSelection, | | 215 | + runtimeMode: "full-access", | | 216 | + interactionMode: "default", | | 217 | + branch: null, | | 218 | + worktreePath: null, | | 219 | + activeProviderThreadId: providerThread.id, | | 220 | + lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId }, | | 221 | + forkedFrom: null, | | 222 | + createdAt: now, | | 223 | + updatedAt: now, | | 224 | + archivedAt: null, | | 225 | + settledOverride: null, | | 226 | + settledAt: null, | | 227 | + lastVisitedAt: null, | | 228 | + deletedAt: null, | | 229 | + }, | | 230 | + threadId, | | 231 | + runId: RunId.make(`run-model-${ordinal}`), | | 232 | + runOrdinal: ordinal, | | 233 | + providerTurnOrdinal: ordinal, | | 234 | + attemptId: RunAttemptId.make(`attempt-model-${ordinal}`), | | 235 | + rootNodeId: NodeId.make(`node-model-${ordinal}`), | | 236 | + providerThread, | | 237 | + message: { | | 238 | + createdBy: "user", | | 239 | + creationSource: "web", | | 240 | + messageId: MessageId.make(`message-model-${ordinal}`), | | 241 | + text: "Report the selected model", | | 242 | + attachments: [], | | 243 | + }, | | 244 | + modelSelection, | | 245 | + runtimePolicy, | | 246 | + }); | | 247 | + const events = yield* Fiber.join(completed); | | 248 | + return events | | 249 | + .filter( | | 250 | + (event) => event.type === "message.updated" && event.message.role === "assistant", | | 251 | + ) | | 252 | + .map((event) => (event.type === "message.updated" ? event.message.text : undefined)) | | 253 | + .at(-1); | | 254 | + }); | | 255 | + assert.equal(yield* turn(1, savedModel), "gemini-3.8-flash-low"); | | 256 | + yield* Scope.close(freshScope, Exit.void); | | 257 | + assert.isNotNull(providerThread.nativeThreadRef?.nativeId); | | 258 | + session = yield* adapter.openSession({ | | 259 | + ...open, | | 260 | + initialNativeThreadId: providerThread.nativeThreadRef!.nativeId!, | | 261 | + }); | | 262 | + yield* session.resumeThread({ providerThread }); | | 263 | + assert.equal(yield* turn(2, savedModel), "gemini-3.8-flash-low"); | | 264 | + assert.equal( | | 265 | + yield* turn(3, { | | 266 | + instanceId, | | 267 | + model: ANTIGRAVITY_DEFAULT_MODEL, | | 268 | + options: [{ id: "thinking_level", value: "low" }], | | 269 | + }), | | 270 | + "gemini-3.8-flash-low", | | 271 | + ); | | 272 | + assert.equal( | | 273 | + yield* turn(4, { instanceId, model: ANTIGRAVITY_DEFAULT_MODEL }), | | 274 | + "gemini-3.8-flash-high", | | 275 | + ); | | 276 | + const requests = yield* Effect.forEach( | | 277 | + (yield* fileSystem.readFileString(logPath)).trim().split("\n"), | | 278 | + (line) => decodeAntigravity140Request(line), | | 279 | + ); | | 280 | + assert.equal(requests.filter((request) => request.method === "session/new").length, 1); | | 281 | + assert.equal(requests.filter((request) => request.method === "session/resume").length, 1); | | 282 | + assert.deepEqual( | | 283 | + requests | | 284 | + .filter((request) => request.method === "session/set_model") | | 285 | + .map((request) => request.params?.modelId), | | 286 | + [ | | 287 | + "gemini-3.8-flash-low", | | 288 | + "gemini-3.8-flash-low", | | 289 | + "gemini-3.8-flash-high", | | 290 | + "gemini-3.8-flash-high", | | 291 | + ], | | 292 | + ); | | 293 | + }).pipe(Effect.provide(layerSession), Effect.scoped), | | 294 | + ); | | 295 | +}); | | 296 | + | 173 | 297 | describe("AntigravityAdapterV2 client file system", () => { | 174 | 298 | it.effect("confines agent file requests to the workspace under full access", () => | 175 | 299 | Effect.gen(function* () { | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/AntigravityProvider.test.ts +13-11Lines changed: 13 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -180,14 +180,6 @@ const makeHarness = Effect.fn("makeAntigravityProviderHarness")(function* ( | 180 | 180 | }); | 181 | 181 |
| 182 | 182 | describe("Antigravity model catalog", () => { | 183 | | - it("keeps ACP 1.4 concrete models and the selected thinking level", () => { | 184 | | - const models = buildAntigravityModelsFromSession(antigravity140Session); | 185 | | - expect(models.map((model) => model.slug)).toEqual( | 186 | | - antigravity140Session.models.availableModels.map((model) => model.modelId), | 187 | | - ); | 188 | | - expect(models.find((model) => model.isDefault)?.slug).toBe("gemini-3.8-flash-high"); | 189 | | - }); | 190 | | - | 191 | 183 | it("keeps the captured personal catalog's IDs, labels, order, and selected default", () => { | 192 | 184 | const models = buildAntigravityModelsFromSession(sessionSetupResult); | 193 | 185 | expect(models.map((model) => [model.slug, model.name])).toEqual( | @@ -253,11 +245,21 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { | 253 | 245 | ...started, | 254 | 246 | sessionSetupResult: antigravity140Session, | 255 | 247 | }); | 256 | | - yield* harness.provider.onConfigOptionsUpdated(antigravity140Session.configOptions); | 257 | 248 | const snapshot = yield* harness.provider.snapshot.getSnapshot; | 258 | | - expect(snapshot.models.map((model) => model.slug)).toEqual( | 259 | | - antigravity140Session.models.availableModels.map((model) => model.modelId), | | 249 | + expect(snapshot.models.map((model) => [model.slug, model.name])).toEqual([ | | 250 | + ["gemini-3.8-flash-high", "Gemini 3.8 Flash (High)"], | | 251 | + ["gemini-3.8-flash-medium", "Gemini 3.8 Flash (Medium)"], | | 252 | + ["gemini-3.8-flash-low", "Gemini 3.8 Flash (Low)"], | | 253 | + ]); | | 254 | + expect(snapshot.models.find((model) => model.isDefault)?.slug).toBe( | | 255 | + "gemini-3.8-flash-high", | | 256 | + ); | | 257 | + yield* harness.provider.onConfigOptionsUpdated( | | 258 | + antigravity140Session.configOptions.map((option) => | | 259 | + option.id === "thinking_level" ? { ...option, currentValue: "low" } : option, | | 260 | + ), | 260 | 261 | ); | | 262 | + expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual(snapshot.models); | 261 | 263 | yield* harness.provider.onSessionStarted(started); | 262 | 264 | yield* harness.provider.onConfigOptionsUpdated([ | 263 | 265 | { ...modelConfig, options: modelOptions.slice(0, 1) }, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/AntigravityProvider.ts +16-21Lines changed: 16 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,6 +31,7 @@ import { | 31 | 31 | type ServerProviderDraft, | 32 | 32 | } from "@t3tools/provider-core/server/snapshotProbe"; | 33 | 33 | import { resolveUsageLimitsAfterProbe } from "@t3tools/provider-core/server/usageLimits"; | | 34 | +import { antigravitySessionModels } from "./acp/AntigravityAcpSupport.ts"; | 34 | 35 |
| 35 | 36 | const EMPTY_MODEL_CAPABILITIES = createModelCapabilities({ optionDescriptors: [] }); | 36 | 37 | const MAX_WORKSPACE_SNAPSHOTS = 32; | @@ -47,18 +48,13 @@ type SessionSetupResult = Pick< | 47 | 48 | export function buildAntigravityModelsFromSession( | 48 | 49 | setup: SessionSetupResult, | 49 | 50 | ): ReadonlyArray<ServerProviderModel> { | 50 | | - const config = setup.configOptions?.find( | 51 | | - (option) => option.id === "model" || option.category === "model", | 52 | | - ); | 53 | | - const models = setup.configOptions?.some((option) => option.id === "thinking_level") | 54 | | - ? setup.models | 55 | | - : undefined; | | 51 | + const config = antigravitySessionModels(setup) | | 52 | + ? undefined | | 53 | + : setup.configOptions?.find((option) => option.id === "model" || option.category === "model"); | 56 | 54 | const currentValue = | 57 | | - models?.currentModelId ?? | 58 | | - (config?.type === "select" ? config.currentValue : setup.models?.currentModelId); | 59 | | - const entries = models | 60 | | - ? models.availableModels.map((model) => ({ value: model.modelId, name: model.name })) | 61 | | - : config?.type === "select" | | 55 | + config?.type === "select" ? config.currentValue : setup.models?.currentModelId; | | 56 | + const entries = | | 57 | + config?.type === "select" | 62 | 58 | ? config.options.flatMap((entry) => ("value" in entry ? [entry] : entry.options)) | 63 | 59 | : config === undefined | 64 | 60 | ? (setup.models?.availableModels.map((model) => ({ | @@ -120,7 +116,7 @@ function isMissingInstallation(error: EffectAcpErrors.AcpError | ProviderSetupEr | 120 | 116 | interface AntigravityProviderState { | 121 | 117 | readonly draft: ServerProviderDraft; | 122 | 118 | readonly authRevision: number; | 123 | | - readonly usesSessionModels: boolean; | | 119 | + readonly sessionModels: EffectAcpSchema.SessionModelState | null; | 124 | 120 | } | 125 | 121 |
| 126 | 122 | interface AntigravityProviderOptions { | @@ -165,7 +161,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func | 165 | 161 | const metadata = yield* SubscriptionRef.make<AntigravityProviderState>({ | 166 | 162 | draft: initialDraft, | 167 | 163 | authRevision: 0, | 168 | | - usesSessionModels: false, | | 164 | + sessionModels: null, | 169 | 165 | }); | 170 | 166 | // Skills the driver discovered on disk per workspace. Session callbacks | 171 | 167 | // rewrite the workspace entry with native commands and must keep these, or | @@ -296,11 +292,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func | 296 | 292 | const workspace = cwd ? workspaces.find((entry) => entry.cwd === cwd) : undefined; | 297 | 293 | return { | 298 | 294 | authRevision: state.authRevision + 1, | 299 | | - usesSessionModels: | 300 | | - started.sessionSetupResult.models != null && | 301 | | - started.sessionSetupResult.configOptions?.some( | 302 | | - (option) => option.id === "thinking_level", | 303 | | - ) === true, | | 295 | + sessionModels: antigravitySessionModels(started.sessionSetupResult), | 304 | 296 | draft: { | 305 | 297 | ...draft, | 306 | 298 | installed: true, | @@ -339,9 +331,12 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func | 339 | 331 | const onConfigOptionsUpdated = Effect.fn("AntigravityProvider.onConfigOptionsUpdated")(function* ( | 340 | 332 | configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>, | 341 | 333 | ) { | 342 | | - const models = buildAntigravityModelsFromSession({ configOptions }); | 343 | 334 | yield* SubscriptionRef.update(metadata, (state) => { | 344 | | - if (state.draft.auth.status !== "authenticated" || state.usesSessionModels) return state; | | 335 | + if (state.draft.auth.status !== "authenticated") return state; | | 336 | + const models = buildAntigravityModelsFromSession({ | | 337 | + configOptions, | | 338 | + models: state.sessionModels, | | 339 | + }); | 345 | 340 | return { ...state, draft: { ...state.draft, models } }; | 346 | 341 | }); | 347 | 342 | }); | @@ -390,7 +385,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func | 390 | 385 | (state) => | 391 | 386 | ({ | 392 | 387 | authRevision: state.authRevision + 1, | 393 | | - usesSessionModels: false, | | 388 | + sessionModels: null, | 394 | 389 | draft: { | 395 | 390 | ...state.draft, | 396 | 391 | auth: { status: "unauthenticated" }, | |
|