Skip to main content
When an agent tackles a task it usually takes multiple steps—invoking tools, writing code, making API calls, and reasoning along the way. Even if the final answer is right, a poor sequence of steps can waste time, money, or expose users to risk. Individual span or trace evaluations check that one step or response is correct, but they can miss costly mistakes an agent makes between steps. Agent trajectory evaluations measure the entire sequence of tool calls an agent takes to solve a task.
Agent Trajectory Eval
A Colab notebook that walks through the complete workflow is available in the Agent Trajectory Evaluation Notebook.

How It Works

  1. Group tool-calling spans per trace – each tool call (function call) is captured as a span when you instrument with OpenInference.
  2. Send the ordered list of tool calls to an LLM judge – Phoenix Evals classifies the trajectory as correct or incorrect (and can produce an explanation).
  3. Log the evaluation back to Arize AX – the result is attached to the root span of the trace so you can filter and pivot in the UI.

Prerequisites

  1. Instrumented traces of your agent with the OpenInference schema
  2. Python 3.10+ and the following packages:

Implementation

1. Pull trace data from Arize AX

2. Filter to the spans you want to score

Most agents emit many spans (retrieval, LLM calls, DB writes, …). For trajectory scoring we usually care about LLM spans that contain tool calls.

3. Extract ordered tool calls for each trace

4. Define the evaluation prompt

The LLM judge receives:
  • {tool_calls} – the actual trajectory (step → tool → arguments)
  • {attributes.input.value} – the user input that kicked off the trace
  • {attributes.llm.tools} – the JSON schema of available tools
  • (Optional) {reference_outputs} – a golden trajectory you expect

5. Run the evaluation

6. Log the results back to Arize AX

Link the evaluation to the root span of each trace so you can slice & dice in the UI.