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, 06:00 UTC
fix(antigravity): allow compaction when the runtime advertises it (#37020)
Co-authored-by: 尤嘉兴 <youjiaxing@dianchu.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
YouJiaXing committed
Nov 20, 2026 at 03:45 UTC
cdf5a6c0fc9f0ad68bc2bd462a5f7ce626fdd622
3 files changed
+72
-17
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
+68
-13
@@ -317,16 +317,23 @@ describe("AntigravityAdapterV2 harness recovery", () => {
317
});
318
319
describe("AntigravityAdapterV2 compaction", () => {
320
- it.live.each([false, true])(
321
- "negotiates native goals (%s) without enabling manual compaction",
322
- (nativeGoals) =>
320
+ it.live.each([
321
+ { nativeGoals: false, compact: false },
322
+ { nativeGoals: true, compact: false },
323
+ { nativeGoals: false, compact: true },
324
+ ])(
325
+ "negotiates native goals ($nativeGoals) and advertised compaction ($compact)",
326
+ ({ nativeGoals, compact }) =>
327
Effect.gen(function* () {
328
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
329
+ const fileSystem = yield* FileSystem.FileSystem;
330
const path = yield* Path.Path;
331
const crypto = yield* SecureRandom.SecureRandom;
332
const mockAgentPath = yield* path.fromFileUrl(
333
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
334
);
335
+ const logs = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-ag-compact-" });
336
+ const requestLog = path.join(logs, "requests.ndjson");
337
const instanceId = ProviderInstanceId.make("antigravity-compaction-test");
338
const goalSupport = yield* Ref.make(false);
339
const startupMilestone = yield* Deferred.make<void>();
@@ -346,7 +353,11 @@ describe("AntigravityAdapterV2 compaction", () => {
353
command: process.execPath,
354
args: [mockAgentPath],
355
cwd: input.cwd,
349
- env: { T3_ACP_ANTIGRAVITY: "1" },
356
+ env: {
357
+ T3_ACP_ANTIGRAVITY: "1",
358
+ T3_ACP_AVAILABLE_COMMANDS: compact ? "compact" : "",
359
+ T3_ACP_REQUEST_LOG_PATH: requestLog,
360
+ },
361
},
362
}).pipe(
363
Effect.provideService(SecureRandom.SecureRandom, crypto),
@@ -375,28 +386,72 @@ describe("AntigravityAdapterV2 compaction", () => {
386
)
387
: Effect.void,
388
});
389
+ const threadId = ThreadId.make("thread-antigravity-compaction");
390
+ const modelSelection = { instanceId, model: "gemini-test-low" } as const;
391
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
392
+ runtimeMode: "full-access",
393
+ interactionMode: "default",
394
+ cwd: process.cwd(),
395
+ });
396
const opening = yield* adapter
397
.openSession({
380
- threadId: ThreadId.make("thread-antigravity-compaction"),
398
+ threadId,
399
providerSessionId: ProviderSessionId.make("provider-session-antigravity-compaction"),
382
- modelSelection: { instanceId, model: "gemini-test-low" },
383
- runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
384
- runtimeMode: "full-access",
385
- interactionMode: "default",
386
- cwd: process.cwd(),
387
- }),
400
+ modelSelection,
401
+ runtimePolicy,
402
})
403
.pipe(Effect.forkScoped);
404
yield* Deferred.await(startupMilestone);
405
yield* Deferred.succeed(consumeStartupCommands, undefined);
406
const session = yield* Fiber.join(opening);
407
assert.deepEqual(yield* Ref.get(workspaceCommands), {
394
- names: ["plan", "logout"],
408
+ names: compact ? ["compact"] : ["plan", "logout"],
409
cwd: process.cwd(),
410
});
397
- assert.isUndefined(session.compactThread);
411
+ const compactThread = session.compactThread;
412
+ assert.isDefined(compactThread);
413
assert.equal(session.providerSession.capabilities.turns.supportsNativeGoals, nativeGoals);
414
assert.equal((yield* adapter.getCapabilities()).turns.supportsNativeGoals, nativeGoals);
415
+ const providerThread = yield* session.ensureThread({
416
+ threadId,
417
+ modelSelection,
418
+ runtimePolicy,
419
+ });
420
+ const turnInput = makeTurnInput({
421
+ threadId,
422
+ providerThread,
423
+ instanceId,
424
+ modelSelection,
425
+ runtimePolicy,
426
+ now: yield* DateTime.now,
427
+ messageText: "Compact the conversation.",
428
+ });
429
+ if (compact) {
430
+ yield* compactThread!(turnInput);
431
+ const events = yield* session.events.pipe(
432
+ Stream.takeUntil((event) => event.type === "turn.terminal"),
433
+ Stream.runCollect,
434
+ );
435
+ assert.isTrue(
436
+ events.some(
437
+ (event) =>
438
+ event.type === "turn_item.updated" &&
439
+ event.turnItem.type === "compaction" &&
440
+ event.turnItem.status === "completed",
441
+ ),
442
+ );
443
+ } else {
444
+ const error = yield* compactThread!(turnInput).pipe(Effect.flip);
445
+ assert.instanceOf(error, ProviderAdapter.ProviderAdapterTurnStartError);
446
+ assert.instanceOf(error.cause, ProviderAdapter.ProviderCompactionUnsupportedError);
447
+ }
448
+ const prompts = (yield* fileSystem.readFileString(requestLog))
449
+ .trim()
450
+ .split("\n")
451
+ .map((line) => JSON.parse(line) as { method?: string; params?: { prompt?: unknown } })
452
+ .filter((request) => request.method === "session/prompt")
453
+ .map((request) => request.params?.prompt);
454
+ assert.deepEqual(prompts, compact ? [[{ type: "text", text: "/compact" }]] : []);
455
}).pipe(Effect.provide(layerSession)),
456
);
457
});
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
+1
-2
@@ -294,8 +294,7 @@ export function makeAntigravityAcpAdapterFlavor(
294
normalizeToolCall: normalizeAntigravityToolCall,
295
extractSubagentUpdate: extractAntigravitySubagentUpdate,
296
supportsImagePrompts: true,
297
- // ACP 1.3.0 treats /compact as ordinary model input.
298
- supportsCompaction: false,
297
+ compactViaAdvertisedCommand: true,
298
requiresSignIn: isAntigravitySignInRequiredError,
299
// Antigravity can leave a prompt open without updates; long tools and approvals pause this.
300
promptInactivityTimeout: "15 minutes",
docs/user/providers-antigravity.md
+3
-2
@@ -98,8 +98,9 @@ Antigravity. Antigravity cannot rewind its own conversation, so the next turn
98
starts a fresh Antigravity session and T3 Code sends it the kept conversation,
99
without the turns you removed.
100
101
-Manual context compaction is unavailable through Antigravity's ACP runtime, even
102
-though its CLI has `/compact`. Send `/clear` when you need a fresh context.
101
+Use `/compact` to summarize a long conversation when your Antigravity runtime
102
+offers that command. If it is unavailable, update Antigravity in provider settings
103
+or send `/clear` when you need a fresh context.
104
105
### Skills and attachments
106