fix: remove misleading write byte counts

The write tools reported UTF-16 code units as bytes. Remove the count from success messages instead of scanning content again.

Closes #8979
This commit is contained in:
David Brailovsky
2026-09-02 15:06:06 +02:00
parent 8d1b1178cd
commit e583b290a6
6 changed files with 9 additions and 5 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed the write tool reporting UTF-16 code-unit counts as byte counts by removing the misleading count ([#8979](https://github.com/earendil-works/pi/issues/8979)).
## [0.84.4] - 2026-08-28
### Breaking Changes
+1 -1
View File
@@ -30,7 +30,7 @@ export function createWriteTool<TContext extends ExecutionToolContext = Executio
getOrThrow(await env.writeFile(absolutePath, content, signal));
if (signal?.aborted) throw new Error("Operation aborted");
return {
content: [{ type: "text", text: `Successfully wrote ${content.length} bytes to ${path}` }],
content: [{ type: "text", text: `Successfully wrote to ${path}` }],
details: undefined,
};
});
+1 -1
View File
@@ -263,7 +263,7 @@ describe("AgentHarness tools", () => {
context,
);
expect(textOutput(result)).toBe("Successfully wrote 5 bytes to nested/dir/file.txt");
expect(textOutput(result)).toBe("Successfully wrote to nested/dir/file.txt");
expect(getOrThrow(await context.env.readTextFile("nested/dir/file.txt"))).toBe("hello");
});
+1
View File
@@ -4,6 +4,7 @@
### Fixed
- Fixed the write tool reporting UTF-16 code-unit counts as byte counts by removing the misleading count ([#8979](https://github.com/earendil-works/pi/issues/8979)).
- Fixed proxied plain-HTTP provider requests hanging after a tool call by tunneling them with CONNECT ([#8134](https://github.com/earendil-works/pi/issues/8134)).
## [0.84.4] - 2026-08-28
@@ -226,7 +226,7 @@ export function createWriteToolDefinition(
throwIfAborted();
return {
content: [{ type: "text", text: `Successfully wrote ${content.length} bytes to ${path}` }],
content: [{ type: "text", text: `Successfully wrote to ${path}` }],
details: undefined,
};
});
+1 -2
View File
@@ -256,8 +256,7 @@ describe("Coding Agent Tools", () => {
const result = await writeTool.execute("test-call-3", { path: testFile, content });
expect(getTextOutput(result)).toContain("Successfully wrote");
expect(getTextOutput(result)).toContain(testFile);
expect(getTextOutput(result)).toBe(`Successfully wrote to ${testFile}`);
expect(result.details).toBeUndefined();
});