diff --git a/src/agents/pi-embedded-helpers.ts b/src/agents/pi-embedded-helpers.ts index 908940848..850e3cac1 100644 --- a/src/agents/pi-embedded-helpers.ts +++ b/src/agents/pi-embedded-helpers.ts @@ -110,7 +110,9 @@ export async function sanitizeSessionMessagesImages( : undefined; const toolUseId = (toolMsg as { toolUseId?: unknown }).toolUseId; const sanitizedToolUseId = - options?.sanitizeToolCallIds && typeof toolUseId === "string" && toolUseId + options?.sanitizeToolCallIds && + typeof toolUseId === "string" && + toolUseId ? sanitizeToolCallId(toolUseId) : undefined; const sanitizedMsg = {