standard-tests[patch]: test ToolMessage.status="error" (#25210)

This commit is contained in:
Bagatur 2024-08-09 13:00:14 -07:00 committed by GitHub
parent dadb6f1445
commit ca9dcee940
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -481,3 +481,31 @@ class ChatModelIntegrationTests(ChatModelTests):
),
]
model.bind_tools([color_picker]).invoke(messages)
def test_tool_message_error_status(self, model: BaseChatModel) -> None:
"""Test that ToolMessage with status='error' can be handled."""
if not self.has_tool_calling:
pytest.skip("Test requires tool calling.")
model_with_tools = model.bind_tools([my_adder_tool])
messages = [
HumanMessage("What is 1 + 2"),
AIMessage(
"",
tool_calls=[
{
"name": "my_adder_tool",
"args": {"a": 1},
"id": "abc123",
"type": "tool_call",
},
],
),
ToolMessage(
"Error: Missing required argument 'b'.",
name="my_adder_tool",
tool_call_id="abc123",
status="error",
),
]
result = model_with_tools.invoke(messages)
assert isinstance(result, AIMessage)