@devries-cameron20 / t3code Mirror · read-only / commits / df09ced768
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): keep truncated command text valid Unicode (#39697)

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

Simone committed Nov 20, 2026 at 14:26 UTC df09ced7688dec80a9c66c80181144cfb50f62ce
2 files changed +30 -8
apps/server/src/provider/acp/AntigravityProtocol.test.ts
+15 -1
@@ -491,7 +491,7 @@ describe("Antigravity tool results", () => {
491 expect(JSON.stringify(event.rawPayload)).not.toContain("formatted_output");
492 });
493
494 - it("keeps 1.5 command output and its content text valid Unicode when cut", () => {
494 + it("keeps 1.5 command input and output valid Unicode when cut", () => {
495 const tail = `${"x".repeat(7_982)}build completed\r\n`;
496 const output = `Command output:\nprefix\r\n🚀${tail}`;
497 const expected = `[Earlier output truncated]\n\n${tail}`;
@@ -500,12 +500,15 @@ describe("Antigravity tool results", () => {
500 ...commandCompleted,
501 update: {
502 ...commandCompleted.update,
503 + rawInput: { CommandLine: output },
504 rawOutput: { output, exit_code: 0 },
505 content: [{ type: "content", content: { type: "text", text: output } }],
506 },
507 }).toolCall,
508 );
509 + expect(toolCall.command).toBe(expected.trimEnd());
510 expect(toolCall.data).toMatchObject({
511 + rawInput: { CommandLine: expected },
512 rawOutput: { output: expected },
513 content: [{ content: { text: expected.trimEnd() } }],
514 });
@@ -570,6 +573,17 @@ describe("Antigravity tool results", () => {
573 expect(serialized).not.toContain("image-blob");
574 expect(serialized).not.toContain("inline-image");
575 expect(serialized).not.toContain("inline-data-url");
576 +
577 + // Leave three UTF-16 units for the retained output.
578 + const padding = Object.fromEntries(
579 + Array.from({ length: 7 }, (_, index) => [index, "x".repeat(8_000)]),
580 + );
581 + expect(
582 + sanitizeAntigravityToolPayload({
583 + rawOutput: { ...padding, tail: "x".repeat(7_997) },
584 + item: { aggregatedOutput: "🚀ok" },
585 + }),
586 + ).toMatchObject({ item: { aggregatedOutput: "[Earlier output truncated]\n\nok" } });
587 });
588 });
589
apps/server/src/provider/acp/AntigravityProtocol.ts
+15 -7
@@ -179,7 +179,7 @@ function boundText(text: string, limit = TOOL_TEXT_LIMIT): string {
179 : copyBoundedText(`${TOOL_TEXT_TRUNCATED}${text.slice(-limit)}`);
180 }
181
182 -function boundCommandOutput(text: string, limit = TOOL_TEXT_LIMIT): string {
182 +function boundCommandText(text: string, limit = TOOL_TEXT_LIMIT): string {
183 if (
184 text.length <= limit ||
185 (text.length <= limit + TOOL_TEXT_TRUNCATED.length && text.startsWith(TOOL_TEXT_TRUNCATED))
@@ -190,8 +190,17 @@ function boundCommandOutput(text: string, limit = TOOL_TEXT_LIMIT): string {
190 return copyBoundedText(`${TOOL_TEXT_TRUNCATED}${tail}`);
191 }
192
193 -// 1.5 runtimes report command output as `output` and repeat it as content `text`.
194 -const OUTPUT_TEXT_FIELDS = new Set(["combinedOutput", "combined_output", "output", "text"]);
193 +const COMMAND_TEXT_FIELDS = new Set([
194 + "CommandLine",
195 + "command_line",
196 + "commandLine",
197 + "command",
198 + "aggregatedOutput",
199 + "combinedOutput",
200 + "combined_output",
201 + "output",
202 + "text",
203 +]);
204
205 /** Keeps the tail of long tool text, as every bounded tool payload does. */
206 export { boundText as boundAntigravityToolText };
@@ -218,7 +227,7 @@ function sanitizeToolValue(
227 return undefined;
228 }
229 const bound =
221 - field !== undefined && OUTPUT_TEXT_FIELDS.has(field) ? boundCommandOutput : boundText;
230 + field !== undefined && COMMAND_TEXT_FIELDS.has(field) ? boundCommandText : boundText;
231 const text = bound(value, Math.min(TOOL_TEXT_LIMIT, budget.text));
232 budget.text -= text.length;
233 return text;
@@ -455,7 +464,7 @@ export function normalizeAntigravityToolCall(
464 output?.commandLine ??
465 output?.command_line ??
466 toolCall.command;
458 - const command = nativeCommand?.trim() ? boundText(nativeCommand.trim()) : undefined;
467 + const command = nativeCommand?.trim() ? boundCommandText(nativeCommand.trim()) : undefined;
468 const nativeCwd =
469 input?.Cwd ??
470 input?.WorkingDirectory ??
@@ -466,8 +475,7 @@ export function normalizeAntigravityToolCall(
475 output?.working_dir;
476 const cwd = nativeCwd?.trim() ? boundText(nativeCwd.trim()) : undefined;
477 const nativeOutput = output?.combinedOutput ?? output?.combined_output;
469 - const aggregatedOutput =
470 - nativeOutput === undefined ? undefined : boundCommandOutput(nativeOutput);
478 + const aggregatedOutput = nativeOutput === undefined ? undefined : boundCommandText(nativeOutput);
479 const exitCode = output?.exitCode ?? output?.exit_code;
480 const imagePath = localImagePath(output?.imagePath);
481 const sanitizedData = sanitizeAntigravityToolPayload(toolCall.data);