# `LangChain.Trajectory.Assertions`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/trajectory/assertions.ex#L1)

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

# `assert_called_before`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/trajectory/assertions.ex#L99)
*macro* 

Assert that tool `name_a` was called before tool `name_b`.

Wraps `LangChain.Trajectory.called_before?/4` and accepts the same options:

  * `:require_both` — when `true`, a missing tool raises rather than failing
    the ordering check (see `LangChain.Trajectory.called_before?/4`)

## Examples

    assert_called_before trajectory, "search", "answer"
    assert_called_before trajectory, "search", "answer", require_both: true

# `assert_trajectory`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/trajectory/assertions.ex#L38)
*macro* 

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.

# `refute_called_before`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/trajectory/assertions.ex#L128)
*macro* 

Assert that tool `name_a` was NOT called before tool `name_b`.

Accepts the same options as `assert_called_before/4`. Note that with the
default options a missing tool makes this pass vacuously; pass
`require_both: true` to surface a missing tool as an error instead.

## Examples

    refute_called_before trajectory, "write_file", "read_file"

# `refute_trajectory`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/trajectory/assertions.ex#L67)
*macro* 

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
