The best way to control Claude Code, Codex and more from any computer or phone
fix(antigravity): keep complete transcript steps at the tail boundary (#39855)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Simone committed
Nov 20, 2026 at 20:54 UTC
ad4d0f0659b0b147591724999b0e2f1d59d4b42e
2 files changed
+39
-8
apps/server/src/provider/acp/AntigravityChildWork.test.ts
+25
@@ -235,6 +235,31 @@ it.layer(NodeServices.layer)("readAntigravityChildWork", (it) => {
235
expect(child?.steps?.length).toBeLessThan(40);
236
expect(child?.steps?.at(-1)?.text).toBe("marker 4242 found");
237
expect(child?.steps?.[0]?.text?.length).toBeLessThanOrEqual(4_001);
238
+
239
+ const lastLine = JSON.stringify(transcriptLines[3]) + "\n";
240
+ const step = { step_index: 2, type: "VIEW_FILE", content: "" };
241
+ const remaining = 256 * 1024 - Buffer.byteLength(JSON.stringify(step) + "\n" + lastLine);
242
+ const firstLine = JSON.stringify({
243
+ ...step,
244
+ content: "é".repeat(Math.floor(remaining / 2)) + "x".repeat(remaining % 2),
245
+ });
246
+ const aligned = yield* makeProfile({
247
+ steps: autoApproved,
248
+ transcript: `${filler}\n${firstLine}\n${lastLine}`,
249
+ });
250
+ const [alignedChild] = yield* read(aligned.profile, `${ROOT}:1`);
251
+ expect(alignedChild).toMatchObject({
252
+ truncated: true,
253
+ steps: [{ index: 2 }, { index: 3 }],
254
+ });
255
+
256
+ const paddedLine = firstLine.padEnd(firstLine.length + Buffer.byteLength(lastLine) + 1);
257
+ const undelimited = yield* makeProfile({
258
+ steps: autoApproved,
259
+ transcript: filler + paddedLine,
260
+ });
261
+ const [undelimitedChild] = yield* read(undelimited.profile, `${ROOT}:1`);
262
+ expect(undelimitedChild).toMatchObject({ truncated: true, steps: [] });
263
}),
264
);
265
apps/server/src/provider/acp/AntigravityChildWork.ts
+14
-8
@@ -405,14 +405,20 @@ async function readChildTranscript(
405
try {
406
const stat = await handle.stat();
407
if (!stat.isFile()) return undefined;
408
- const length = Math.min(stat.size, byteCap);
409
- const buffer = Buffer.alloc(length);
410
- const { bytesRead } = await handle.read(buffer, 0, length, stat.size - length);
411
- const truncated = stat.size > length;
412
- let contents = buffer.subarray(0, bytesRead).toString("utf8");
413
- // A tail read starts mid-line.
414
- if (truncated) contents = contents.slice(contents.indexOf("\n") + 1);
415
- return { steps: transcriptSteps(contents, prompt), truncated };
408
+ const tailStart = Math.max(0, stat.size - byteCap);
409
+ // One extra byte tells whether the retained tail starts on a line boundary.
410
+ const readStart = Math.max(0, tailStart - 1);
411
+ const buffer = Buffer.alloc(stat.size - readStart);
412
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, readStart);
413
+ const bytes = buffer.subarray(0, bytesRead);
414
+ let lineStart = 0;
415
+ if (tailStart > 0) {
416
+ const newline = bytes.indexOf(0x0a);
417
+ if (newline === -1) return { steps: [], truncated: true };
418
+ lineStart = newline + 1;
419
+ }
420
+ const contents = bytes.toString("utf8", lineStart);
421
+ return { steps: transcriptSteps(contents, prompt), truncated: tailStart > 0 };
422
} finally {
423
await handle.close();
424
}