From 5fe57f8afa39de947c957d7140d80ec01de314c3 Mon Sep 17 00:00:00 2001 From: 04cb <0x04cb@gmail.com> Date: Fri, 29 May 2026 22:06:43 +0800 Subject: [PATCH] fix(providers): coerce typeless Anthropic content blocks to text (#3993) --- nanobot/providers/anthropic_provider.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nanobot/providers/anthropic_provider.py b/nanobot/providers/anthropic_provider.py index 31f2bc2f1..504c35ad0 100644 --- a/nanobot/providers/anthropic_provider.py +++ b/nanobot/providers/anthropic_provider.py @@ -228,6 +228,13 @@ class AnthropicProvider(LLMProvider): if converted: result.append(converted) continue + if not item.get("type"): + # Anthropic requires every content block to declare a "type". + # A tool that returned a bare dict (or a list of dicts) lands + # here; coerce it to a text block instead of emitting a block + # the API rejects with "content.0.type: Field required". + result.append({"type": "text", "text": str(item)}) + continue result.append(item) return result or "(empty)"