From dc2c40468d6c0eca487941c05dd12588b4ecdee1 Mon Sep 17 00:00:00 2001 From: Nathan Hangen Date: Thu, 29 Jan 2026 10:09:47 -0500 Subject: [PATCH] style: fix formatting in session transcript repair --- src/agents/session-transcript-repair.test.ts | 22 ++++++-------------- src/agents/session-transcript-repair.ts | 9 +++++--- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/agents/session-transcript-repair.test.ts b/src/agents/session-transcript-repair.test.ts index 96d42ae1a..5eaff31a1 100644 --- a/src/agents/session-transcript-repair.test.ts +++ b/src/agents/session-transcript-repair.test.ts @@ -118,9 +118,7 @@ describe("sanitizeToolUseArgs", () => { const input = [ { role: "assistant", - content: [ - { type: "toolUse", id: "1", name: "tool", input: { key: "value" } }, - ], + content: [{ type: "toolUse", id: "1", name: "tool", input: { key: "value" } }], }, ] as any; const out = sanitizeToolUseArgs(input); @@ -132,9 +130,7 @@ describe("sanitizeToolUseArgs", () => { const input = [ { role: "assistant", - content: [ - { type: "toolUse", id: "1", name: "tool", input: '{"key": "value"}' }, - ], + content: [{ type: "toolUse", id: "1", name: "tool", input: '{"key": "value"}' }], }, ] as any; const out = sanitizeToolUseArgs(input); @@ -146,25 +142,21 @@ describe("sanitizeToolUseArgs", () => { const input = [ { role: "assistant", - content: [ - { type: "toolUse", id: "1", name: "tool", input: '{ bad json }' }, - ], + content: [{ type: "toolUse", id: "1", name: "tool", input: "{ bad json }" }], }, ] as any; const out = sanitizeToolUseArgs(input); const block = out[0].content[0] as any; expect(block.input).toEqual({}); expect(block._sanitized).toBe(true); - expect(block._originalInput).toBe('{ bad json }'); + expect(block._originalInput).toBe("{ bad json }"); }); it("handles 'arguments' alias", () => { const input = [ { role: "assistant", - content: [ - { type: "toolCall", id: "1", name: "tool", arguments: '{"key": "val"}' }, - ], + content: [{ type: "toolCall", id: "1", name: "tool", arguments: '{"key": "val"}' }], }, ] as any; const out = sanitizeToolUseArgs(input); @@ -176,9 +168,7 @@ describe("sanitizeToolUseArgs", () => { const input = [ { role: "assistant", - content: [ - { type: "toolCall", id: "1", name: "tool", arguments: 'bad' }, - ], + content: [{ type: "toolCall", id: "1", name: "tool", arguments: "bad" }], }, ] as any; const out = sanitizeToolUseArgs(input); diff --git a/src/agents/session-transcript-repair.ts b/src/agents/session-transcript-repair.ts index e5e4786ff..61bcb8f8d 100644 --- a/src/agents/session-transcript-repair.ts +++ b/src/agents/session-transcript-repair.ts @@ -78,11 +78,14 @@ export function sanitizeToolUseArgs(messages: AgentMessage[]): AgentMessage[] { if ( anyBlock && typeof anyBlock === "object" && - (anyBlock.type === "toolUse" || anyBlock.type === "toolCall" || anyBlock.type === "functionCall") + (anyBlock.type === "toolUse" || + anyBlock.type === "toolCall" || + anyBlock.type === "functionCall") ) { const toolBlock = block as any; // Handle both 'input' and 'arguments' fields (some providers use arguments) - const inputField = "input" in toolBlock ? "input" : "arguments" in toolBlock ? "arguments" : null; + const inputField = + "input" in toolBlock ? "input" : "arguments" in toolBlock ? "arguments" : null; if (inputField && typeof toolBlock[inputField] === "string") { try { @@ -97,7 +100,7 @@ export function sanitizeToolUseArgs(messages: AgentMessage[]): AgentMessage[] { // Invalid JSON found in tool args. // Replace with empty object to prevent downstream crashes. console.warn( - `[SessionRepair] Sanitized malformed JSON in tool use '${toolBlock.name || "unknown"}'. Original: ${toolBlock[inputField]}` + `[SessionRepair] Sanitized malformed JSON in tool use '${toolBlock.name || "unknown"}'. Original: ${toolBlock[inputField]}`, ); nextContent.push({ ...toolBlock,