Skip to content

Commit 16bf6fe

Browse files
t3dotggclaude
andcommitted
fix(antigravity): served reads complete right away and duplicate model names are labeled
The agent never completes a subagent's client_view_file call, so its row kept spinning until the turn ended. T3 reports the call completed when it serves the file. The agent can also list two model IDs under one name; later ones now show their ID. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3748c5c commit 16bf6fe

6 files changed

Lines changed: 85 additions & 13 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,16 @@ describe("AntigravityAdapterV2 subagent reads", () => {
896896
: undefined;
897897
};
898898

899+
const firstEvent = (nativeId: string, status: string) =>
900+
events.findIndex(
901+
(event) =>
902+
event.type === "turn_item.updated" &&
903+
event.turnItem.nativeItemRef?.nativeId === nativeId &&
904+
event.turnItem.status === status,
905+
);
906+
// T3 completes a served read itself instead of leaving it running until the flush.
907+
assert.isAbove(firstEvent("call_served", "completed"), -1);
908+
assert.isBelow(firstEvent("call_served", "completed"), firstEvent("call_native", "failed"));
899909
const failed = { status: "failed" as const, output: stepError };
900910
assert.deepEqual(read("call_served"), { status: "completed", output: undefined });
901911
assert.deepEqual(read("call_retried"), { status: "completed", output: undefined });

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as Effect from "effect/Effect";
1111
import * as FileSystem from "effect/FileSystem";
1212
import * as Path from "effect/Path";
1313
import * as Exit from "effect/Exit";
14+
import * as Semaphore from "effect/Semaphore";
1415
import * as Scope from "effect/Scope";
1516
import * as EffectAcpErrors from "effect-acp/errors";
1617

@@ -131,20 +132,40 @@ export function makeAntigravityAcpAdapterFlavor(
131132
.pipe(Effect.provideService(Scope.Scope, scope));
132133
// Repair keeps state across updates, so each runtime must have one session-update handler.
133134
const reads = makeAntigravityReadRepair();
135+
// Served reads are reported from the read handler, so they take turns with agent updates.
136+
const updates = yield* Semaphore.make(1);
137+
let projectUpdate: Parameters<typeof runtime.handleSessionUpdate>[0] | undefined;
134138
return {
135139
...runtime,
136140
handleReadTextFile: (handler) =>
137141
runtime.handleReadTextFile((request, context) =>
138142
handler(request, context).pipe(
139-
Effect.onExit((exit) =>
140-
Effect.sync(() => reads.attempted(request.path, Exit.isSuccess(exit))),
141-
),
143+
Effect.onExit((exit) => {
144+
const served = reads.attempted(request.path, Exit.isSuccess(exit));
145+
if (served === undefined || projectUpdate === undefined) return Effect.void;
146+
return updates
147+
.withPermit(
148+
projectUpdate({
149+
sessionId: served.sessionId,
150+
update: {
151+
sessionUpdate: "tool_call_update",
152+
toolCallId: served.toolCallId,
153+
status: "completed",
154+
},
155+
}),
156+
)
157+
.pipe(Effect.ignore);
158+
}),
142159
),
143160
),
144161
prompt: (payload, promptOptions) =>
145162
Effect.sync(reads.reset).pipe(Effect.andThen(runtime.prompt(payload, promptOptions))),
146-
handleSessionUpdate: (handler) =>
147-
runtime.handleSessionUpdate((notification) => handler(reads.repair(notification))),
163+
handleSessionUpdate: (handler) => {
164+
projectUpdate = handler;
165+
return runtime.handleSessionUpdate((notification) =>
166+
updates.withPermit(handler(reads.repair(notification))),
167+
);
168+
},
148169
start: () =>
149170
runtime
150171
.start()

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,25 @@ describe("Antigravity model catalog", () => {
215215
);
216216
});
217217

218+
it("labels models that share a display name with their IDs", () => {
219+
const models = buildAntigravityModelsFromSession({
220+
configOptions: [
221+
{
222+
...modelConfig,
223+
currentValue: "gemini-3.8-flash",
224+
options: [
225+
{ value: "gemini-3.8-flash", name: "Gemini 3.8 Flash" },
226+
{ value: "gemini-3.8-flash-preview", name: "Gemini 3.8 Flash" },
227+
],
228+
},
229+
],
230+
});
231+
expect(models.map((model) => model.name)).toEqual([
232+
"Gemini 3.8 Flash",
233+
"Gemini 3.8 Flash (gemini-3.8-flash-preview)",
234+
]);
235+
});
236+
218237
it("offers each model the thinking levels it reported when selected", () => {
219238
const thinking = (currentValue: string) =>
220239
({

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,20 @@ export function buildAntigravityModelsFromSession(
8282
: [];
8383
const currentThinking = antigravityThinkingConfig(setup.configOptions);
8484
const seen = new Set<string>();
85+
// The agent can list two IDs under one name; label the later ones so the picker tells them apart.
86+
const names = new Set<string>();
8587
return entries.flatMap((entry): ServerProviderModel[] => {
8688
if (!entry.value.trim() || seen.has(entry.value)) return [];
8789
seen.add(entry.value);
90+
const baseName = entry.name.trim() ? entry.name : entry.value;
91+
const name = names.has(baseName) ? `${baseName} (${entry.value})` : baseName;
92+
names.add(baseName);
8893
const observed =
8994
entry.value === currentValue ? (currentThinking ?? null) : thinkingLevels.get(entry.value);
9095
return [
9196
{
9297
slug: entry.value,
93-
name: entry.name.trim() ? entry.name : entry.value,
98+
name,
9499
isCustom: false,
95100
...(entry.value === currentValue
96101
? { isDefault: true, aliases: [ANTIGRAVITY_DEFAULT_MODEL] }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ describe("Antigravity served reads", () => {
430430
it("credits a read T3 served before the agent announced it", () => {
431431
const reads = makeAntigravityReadRepair();
432432
reads.attempted("/repo/a.ts", true);
433-
reads.repair({
433+
const announced = reads.repair({
434434
sessionId: "session-1",
435435
update: {
436436
sessionUpdate: "tool_call",
@@ -441,6 +441,7 @@ describe("Antigravity served reads", () => {
441441
locations: [{ path: "/repo/a.ts" }],
442442
},
443443
});
444+
expect(announced.update).toMatchObject({ status: "completed" });
444445
expect(flush(reads, "call_late")).toEqual({
445446
sessionUpdate: "tool_call_update",
446447
toolCallId: "call_late",

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ function antigravityClientReadPath(update: {
239239
*/
240240
export function makeAntigravityReadRepair() {
241241
type Outcome = "served" | "refused";
242-
const openReads = new Map<string, { readonly path: string; outcome?: Outcome }>();
242+
const openReads = new Map<
243+
string,
244+
{ readonly path: string; readonly sessionId: string; outcome?: Outcome }
245+
>();
243246
// The agent runs a client tool in a background task, so its request can precede the announcement.
244247
const earlyOutcomes: Array<{ readonly path: string; readonly outcome: Outcome }> = [];
245248
return {
@@ -248,15 +251,19 @@ export function makeAntigravityReadRepair() {
248251
openReads.clear();
249252
earlyOutcomes.length = 0;
250253
},
251-
/** Each `fs/read_text_file` request answers the oldest open read of its path, in order. */
254+
/**
255+
* Each `fs/read_text_file` request answers the oldest open read of its path, in order.
256+
* Returns the call a served read completes, so T3 can report it without waiting.
257+
*/
252258
attempted: (path: string, served: boolean) => {
253259
const outcome = served ? "served" : "refused";
254-
for (const read of openReads.values()) {
260+
for (const [toolCallId, read] of openReads) {
255261
if (read.path !== path || read.outcome !== undefined) continue;
256262
read.outcome = outcome;
257-
return;
263+
return served ? { sessionId: read.sessionId, toolCallId } : undefined;
258264
}
259265
earlyOutcomes.push({ path, outcome });
266+
return undefined;
260267
},
261268
repair: (
262269
notification: EffectAcpSchema.SessionNotification,
@@ -269,10 +276,19 @@ export function makeAntigravityReadRepair() {
269276
if (path !== undefined && !openReads.has(update.toolCallId)) {
270277
const early = earlyOutcomes.findIndex((entry) => entry.path === path);
271278
const outcome = early === -1 ? undefined : earlyOutcomes.splice(early, 1)[0]?.outcome;
272-
openReads.set(update.toolCallId, outcome === undefined ? { path } : { path, outcome });
279+
const sessionId = notification.sessionId;
280+
openReads.set(
281+
update.toolCallId,
282+
outcome === undefined ? { path, sessionId } : { path, sessionId, outcome },
283+
);
273284
}
274-
if (update.status !== "completed" && update.status !== "failed") return notification;
275285
const read = openReads.get(update.toolCallId);
286+
if (update.status === "pending" || update.status === "in_progress") {
287+
return read?.outcome === "served"
288+
? { ...notification, update: { ...update, status: "completed" } }
289+
: notification;
290+
}
291+
if (update.status !== "completed" && update.status !== "failed") return notification;
276292
openReads.delete(update.toolCallId);
277293
if (update.status === "completed" || read?.outcome !== "served") return notification;
278294
const { rawOutput: _stepError, ...rest } = update;

0 commit comments

Comments
 (0)