mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-13 22:34:06 +00:00
fix(providers): coerce typeless Anthropic content blocks to text (#3993)
This commit is contained in:
parent
288146315e
commit
5fe57f8afa
@ -228,6 +228,13 @@ class AnthropicProvider(LLMProvider):
|
|||||||
if converted:
|
if converted:
|
||||||
result.append(converted)
|
result.append(converted)
|
||||||
continue
|
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)
|
result.append(item)
|
||||||
return result or "(empty)"
|
return result or "(empty)"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user