feat(HAI-099): remove truncation from summarizeToolArgs

- Remove 80-char truncation from bash command summaries in summarizeToolArgs
- Remove length guard from fallback string-valued arg path
- Update agent-logger tests to expect full strings without truncation
- Add test case for long string-valued fallback args
- Update executor tests to match new non-truncating behavior
This commit is contained in:
Dustin Byrne
2026-03-26 19:33:56 -04:00
parent 5fc95d4e1f
commit 9bb25a15ea
3 changed files with 15 additions and 11 deletions

View File

@@ -10,10 +10,15 @@ describe("summarizeToolArgs", () => {
expect(summarizeToolArgs("bash", { command: "echo hello" })).toBe("echo hello");
});
it("truncates long bash commands at 80 chars", () => {
const longCmd = "a".repeat(100);
it("returns long bash commands in full without truncation", () => {
const longCmd = "a".repeat(200);
const result = summarizeToolArgs("Bash", { command: longCmd });
expect(result).toBe("a".repeat(80) + "…");
expect(result).toBe(longCmd);
});
it("returns long string-valued fallback args without truncation", () => {
const longVal = "x".repeat(200);
expect(summarizeToolArgs("unknown_tool", { description: longVal })).toBe(longVal);
});
it("returns file path for Read/Edit/Write", () => {

View File

@@ -6,7 +6,8 @@ const FLUSH_SIZE_BYTES = 1024;
const FLUSH_INTERVAL_MS = 500;
/**
* Produce a short human-readable summary from tool arguments.
* Produce a human-readable summary from tool arguments.
* Returns the full argument value without truncation.
* Returns `undefined` for unknown tools or when no meaningful arg is found.
*/
export function summarizeToolArgs(name: string, args?: Record<string, unknown>): string | undefined {
@@ -15,9 +16,7 @@ export function summarizeToolArgs(name: string, args?: Record<string, unknown>):
if (lowerName === "bash") {
const cmd = args.command;
if (typeof cmd === "string") {
return cmd.length > 80 ? cmd.slice(0, 80) + "…" : cmd;
}
if (typeof cmd === "string") return cmd;
}
if (lowerName === "read" || lowerName === "edit" || lowerName === "write") {
@@ -25,9 +24,9 @@ export function summarizeToolArgs(name: string, args?: Record<string, unknown>):
if (typeof p === "string") return p;
}
// Fallback: return first string-valued arg if short enough
// Fallback: return first string-valued arg
for (const val of Object.values(args)) {
if (typeof val === "string" && val.length <= 80) return val;
if (typeof val === "string") return val;
}
return undefined;

View File

@@ -883,10 +883,10 @@ describe("summarizeToolArgs", () => {
expect(summarizeToolArgs("bash", { command: "echo hello" })).toBe("echo hello");
});
it("truncates long bash commands to 80 chars", () => {
it("returns long bash commands in full without truncation", () => {
const longCmd = "a".repeat(100);
const result = summarizeToolArgs("Bash", { command: longCmd });
expect(result).toBe("a".repeat(80) + "…");
expect(result).toBe(longCmd);
});
it("returns path for read/edit/write tools", () => {