From 433b42ac9149862a79be22d41580e1be7ab59e3f Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 9 Sep 2025 21:47:40 +0200 Subject: [PATCH] Fix Biome config, don't submit empty assistant messages to completions endpoint. --- biome.json | 3 ++- packages/ai/src/providers/openai-completions.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/biome.json b/biome.json index 5eecf7c4..ac962d29 100644 --- a/biome.json +++ b/biome.json @@ -28,6 +28,7 @@ "lineWidth": 120 }, "files": { - "includes": ["packages/*/src/**/*", "packages/*/test/**/*", "*.json", "*.md"] + "includes": ["packages/*/src/**/*", "packages/*/test/**/*", "*.json", "*.md", "!**/node_modules/**/*"], + "experimentalScannerIgnores": ["node_modules"] } } diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index d21c63a3..1f6c84cc 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -348,7 +348,9 @@ function convertMessages(model: Model<"openai-completions">, context: Context): const textBlocks = msg.content.filter((b) => b.type === "text") as TextContent[]; if (textBlocks.length > 0) { - assistantMsg.content = textBlocks.map((b) => b.text).join(""); + assistantMsg.content = textBlocks.map((b) => { + return { type: "text", text: b.text }; + }); } // Handle thinking blocks for llama.cpp server + gpt-oss @@ -357,7 +359,7 @@ function convertMessages(model: Model<"openai-completions">, context: Context): // Use the signature from the first thinking block if available const signature = thinkingBlocks[0].thinkingSignature; if (signature && signature.length > 0) { - (assistantMsg as any)[signature] = thinkingBlocks.map((b) => b.thinking).join(""); + (assistantMsg as any)[signature] = thinkingBlocks.map((b) => b.thinking).join("\n"); } } @@ -372,7 +374,9 @@ function convertMessages(model: Model<"openai-completions">, context: Context): }, })); } - + if (assistantMsg.content === null && !assistantMsg.tool_calls) { + continue; + } params.push(assistantMsg); } else if (msg.role === "toolResult") { params.push({