fix(llms/anthropic): find the text block in no-tools responses instead of indexing content[0] (#6481)

This commit is contained in:
Ayaan Gazali
2026-07-22 21:34:48 +05:30
committed by GitHub
parent f590c9596a
commit 14393b5962
2 changed files with 58 additions and 1 deletions
+8 -1
View File
@@ -149,4 +149,11 @@ class AnthropicLLM(LLMBase):
elif block.type == "tool_use":
result["tool_calls"].append({"name": block.name, "arguments": block.input})
return result
return response.content[0].text
# Thinking-enabled responses put a thinking block before the text
# block, and a response can carry no text block at all, so find the
# text block like the tools branch above instead of indexing content[0].
for block in response.content:
if block.type == "text":
return block.text
return ""