fix: multi-line bash tool call formatting

This commit is contained in:
Nate 2025-08-27 09:07:27 -07:00
parent 1244afdcc2
commit 711445aac7
2 changed files with 26 additions and 0 deletions

View file

@ -62,6 +62,28 @@ describe("formatToolCall", () => {
}),
).toBe("Write(test.txt)");
});
it("should handle multi-line string arguments with ellipsis", () => {
expect(
formatToolCall("Bash", {
command: "echo 'first line'\necho 'second line'\necho 'third line'",
}),
).toBe("Bash(echo 'first line'...)");
expect(
formatToolCall("Edit", {
old_string: "line 1\nline 2\nline 3",
new_string: "updated content",
}),
).toBe("Edit(line 1...)");
// Test with empty first line
expect(
formatToolCall("Write", {
content: "\nSecond line\nThird line",
}),
).toBe("Write(...)");
});
});
describe("formatToolArgument", () => {

View file

@ -229,6 +229,10 @@ export function formatToolCall(toolName: string, args?: any): string {
const valueLines = value.split("\n");
if (valueLines.length === 1) {
formattedValue = formatToolArgument(value);
} else {
// For multi-line strings, show first line with ellipsis
const firstLine = valueLines[0].trim();
formattedValue = firstLine ? `${formatToolArgument(firstLine)}...` : "...";
}
}