fix(core): preserve ToolMessage.status field in convert_to_messages (#32840)

This commit is contained in:
Jonathan Hill
2025-09-10 14:49:39 -05:00
committed by GitHub
parent 9c7d262ff4
commit 2fed177d0b
2 changed files with 10 additions and 1 deletions

View File

@@ -286,6 +286,9 @@ def _create_message_from_message_type(
message = FunctionMessage(content=content, **kwargs)
elif message_type == "tool":
artifact = kwargs.get("additional_kwargs", {}).pop("artifact", None)
status = kwargs.get("additional_kwargs", {}).pop("status", None)
if status is not None:
kwargs["status"] = status
message = ToolMessage(content=content, artifact=artifact, **kwargs)
elif message_type == "remove":
message = RemoveMessage(**kwargs)

View File

@@ -740,6 +740,7 @@ def test_convert_to_messages() -> None:
"tool_call_id": "tool_id2",
"content": "Bye!",
"artifact": {"foo": 123},
"status": "success",
},
{"role": "remove", "id": "message_to_remove", "content": ""},
{
@@ -773,7 +774,12 @@ def test_convert_to_messages() -> None:
],
),
ToolMessage(tool_call_id="tool_id", content="Hi!"),
ToolMessage(tool_call_id="tool_id2", content="Bye!", artifact={"foo": 123}),
ToolMessage(
tool_call_id="tool_id2",
content="Bye!",
artifact={"foo": 123},
status="success",
),
RemoveMessage(id="message_to_remove"),
HumanMessage(
content="Now the turn for Larry to ask a question about the book!",