Skip to content

Commit d89537f

Browse files
VANDRANKIhlwz5735
andcommitted
fix: ignore empty string reasoning_content in _extract_reasoning_from_additional_kwargs
Some providers (e.g. Groq) include "reasoning_content": "" in additional_kwargs even when no reasoning was produced. The previous check `reasoning_content is not None` treated an empty string as valid, inserting an empty ReasoningContentBlock into the message content list. Change to a truthy check so empty strings are skipped. Fixes #36194 Co-Authored-By: hlwz5735 <12751178+hlwz5735@users.noreply.github.com>
1 parent acc5498 commit d89537f

File tree

1 file changed

+1
-1
lines changed
  • libs/core/langchain_core/messages

1 file changed

+1
-1
lines changed

libs/core/langchain_core/messages/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _extract_reasoning_from_additional_kwargs(
3838
additional_kwargs = getattr(message, "additional_kwargs", {})
3939

4040
reasoning_content = additional_kwargs.get("reasoning_content")
41-
if reasoning_content is not None and isinstance(reasoning_content, str):
41+
if reasoning_content and isinstance(reasoning_content, str):
4242
return {"type": "reasoning", "reasoning": reasoning_content}
4343

4444
return None

0 commit comments

Comments
 (0)