From 3666aac2a1bb3aa9f67150c085a978f9b3a1fd2a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 8 Jan 2026 01:17:46 -0600 Subject: [PATCH] Clone the messages list instead of mutating them --- src/lib/ai-client.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/ai-client.ts b/src/lib/ai-client.ts index a127101b..ae7f86c0 100644 --- a/src/lib/ai-client.ts +++ b/src/lib/ai-client.ts @@ -68,6 +68,7 @@ export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: s // https://openrouter.ai/docs/guides/best-practices/prompt-caching#anthropic-claude if (body.model.startsWith("anthropic/")) { // First normalize the message history to use content blocks + body.messages = structuredClone(body.messages); body.messages = body.messages.map((m) => { if (m.role !== "function" && typeof m.content === "string") { return { ...m, content: [{ type: "text", text: m.content }] };