ExUnit assertion helpers for trajectory comparison.
Usage
use LangChain.Trajectory.Assertions
test "agent calls the right tools" do
trajectory = Trajectory.from_chain(chain)
assert_trajectory trajectory, [
%{name: "search", arguments: %{"query" => "weather"}},
%{name: "get_forecast", arguments: nil}
]
end
test "agent does not call dangerous tool" do
trajectory = Trajectory.from_chain(chain)
refute_trajectory trajectory, [
%{name: "delete_all", arguments: nil}
], mode: :superset
end
Summary
Functions
Assert that a trajectory matches the expected tool call sequence.
Assert that a trajectory does NOT match the expected tool call sequence.
Functions
Assert that a trajectory matches the expected tool call sequence.
Accepts the same options as LangChain.Trajectory.matches?/3:
:mode—:strict(default),:unordered,:superset:args—:exact(default),:subset
On failure, raises ExUnit.AssertionError with a diff showing expected vs
actual tool calls.
Assert that a trajectory does NOT match the expected tool call sequence.
Useful for verifying that specific tools were not called or that a particular call pattern did not occur.
Accepts the same options as assert_trajectory/3.
On failure, raises ExUnit.AssertionError indicating an unexpected match.