The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
core[patch]: return ToolMessage from tools when tool call ID is empty string (#29921)
Vadym Barda437fe6d2164e
diff --git a/libs/core/langchain_core/tools/base.py b/libs/core/langchain_core/tools/base.pyindex ff62f3091d..3d98b50dda 100644--- a/libs/core/langchain_core/tools/base.py+++ b/libs/core/langchain_core/tools/base.py@@ -960,7 +960,7 @@ def _format_output(name: str,status: str,) -> Union[ToolOutputMixin, Any]:- if isinstance(content, ToolOutputMixin) or not tool_call_id:+ if isinstance(content, ToolOutputMixin) or tool_call_id is None:return contentif not _is_message_content_type(content):content = _stringify(content)diff --git a/libs/core/tests/unit_tests/test_tools.py b/libs/core/tests/unit_tests/test_tools.pyindex afe8c09113..06c82946eb 100644--- a/libs/core/tests/unit_tests/test_tools.py+++ b/libs/core/tests/unit_tests/test_tools.py@@ -2457,3 +2457,14 @@ def test_simple_tool_args_schema_dict() -> None:assert tool.args == {"a": {"title": "A", "type": "integer"},}+++def test_empty_string_tool_call_id() -> None:+ @tool+ def foo(x: int) -> str:+ """Foo."""+ return "hi"++ assert foo.invoke({"type": "tool_call", "args": {"x": 0}, "id": ""}) == ToolMessage(+ content="hi", name="foo", tool_call_id=""+ )