fix: multi-line bash tool call formatting
This commit is contained in:
parent
1244afdcc2
commit
711445aac7
2 changed files with 26 additions and 0 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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)}...` : "...";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue