From e6544ddd61580d57a434ef17a38c966763d6f29c Mon Sep 17 00:00:00 2001 From: zerone0x Date: Fri, 27 Feb 2026 23:09:36 +0800 Subject: [PATCH] fix(zen): guard against empty tool_result content in Anthropic provider When a tool call returns an empty string, the Anthropic API rejects the request with "content field is empty". Normalize empty/null/undefined tool content to "(no output)" before sending the request. Fixes #15371 Co-Authored-By: Claude --- .../console/app/src/routes/zen/util/provider/anthropic.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/console/app/src/routes/zen/util/provider/anthropic.ts b/packages/console/app/src/routes/zen/util/provider/anthropic.ts index e2803459e08..3729db4f297 100644 --- a/packages/console/app/src/routes/zen/util/provider/anthropic.ts +++ b/packages/console/app/src/routes/zen/util/provider/anthropic.ts @@ -402,13 +402,19 @@ export function toAnthropicRequest(body: CommonRequest) { } if ((m as any).role === "tool") { + const toolContent = (m as any).content msgsOut.push({ role: "user", content: [ { type: "tool_result", tool_use_id: (m as any).tool_call_id, - content: (m as any).content, + content: + typeof toolContent === "string" && toolContent.length > 0 + ? toolContent + : Array.isArray(toolContent) && toolContent.length > 0 + ? toolContent + : "(no output)", ...cc(), }, ],