Skip to content

Commit bcb9e0c

Browse files
committed
test: add invalid toolcall test
1 parent 8a9426e commit bcb9e0c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/core/test_tool_runner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ def get_image():
3131
}
3232

3333

34+
def test_tool_runner_invalid_call():
35+
runner = ToolRunner(tools=[ros2_topic], logger=logging.getLogger(__name__))
36+
tool_call = ToolCall(name="bad_fn", args={"command": "list"}, id="12345")
37+
state = {"messages": [AIMessage(content="", tool_calls=[tool_call])]}
38+
output = runner.invoke(state)
39+
assert isinstance(
40+
output["messages"][0], AIMessage
41+
), "First message is not an AIMessage"
42+
assert isinstance(
43+
output["messages"][1], ToolMessage
44+
), "Tool output is not a tool message"
45+
assert output["messages"][1].status == "error"
46+
47+
3448
def test_tool_runner():
3549
runner = ToolRunner(tools=[ros2_topic], logger=logging.getLogger(__name__))
3650

0 commit comments

Comments
 (0)