The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix(core): correctly guard against non-text-block types (#34729)
Mason Daugherty3289ee20edd3
diff --git a/libs/core/langchain_core/outputs/chat_generation.py b/libs/core/langchain_core/outputs/chat_generation.pyindex 96605d939e..cebbead8ae 100644--- a/libs/core/langchain_core/outputs/chat_generation.py+++ b/libs/core/langchain_core/outputs/chat_generation.py@@ -57,16 +57,18 @@ class ChatGeneration(Generation):text = ""if isinstance(self.message.content, str):text = self.message.content- # Assumes text in content blocks in OpenAI format.- # Uses first text block.+ # Extracts first text block from content blocks.+ # Skips blocks with explicit non-text type (e.g., thinking, reasoning).elif isinstance(self.message.content, list):for block in self.message.content:if isinstance(block, str):text = blockbreakif isinstance(block, dict) and "text" in block:- text = block["text"]- break+ block_type = block.get("type")+ if block_type is None or block_type == "text":+ text = block["text"]+ breakself.text = textreturn self