mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 08:58:48 +00:00
core[patch]: return ToolMessage from tools when tool call ID is empty string (#29921)
This commit is contained in:
parent
5ee8a8f063
commit
437fe6d216
@ -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 content
|
||||
if not _is_message_content_type(content):
|
||||
content = _stringify(content)
|
||||
|
@ -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=""
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user