AI Hints
Agentic AI · Lesson 69 of 100

Testing the Path

Trajectory evals.

⏱ 2 min read▶ Video at 2:02:33🎓 Free
Watch this lesson in the Agentic AI courseWatch on YouTube ↗Full Agentic AI course

A student gets the right answer on a maths exam, but only by copying from a neighbour. The answer's right, but the process is wrong. An agent can do the same. It might tell a customer the right delivery date, without checking the order. Today that's luck. Tomorrow it's a false promise.

Testing the Path
From the video: Testing the Path
  • The right answer, by copying
  • Agents can do that too
  • Right today, false tomorrow

Checking the tools it used

A trajectory eval looks at which tools the agent used. For each case, we list the steps that we expect. We've also got a list of forbidden tools. Run it. Each case took the expected path, and none of them touched the refund tool. If a change made Juno skip the order lookup, the reply might still look fine, but this eval would catch it.

trajectory.pypython
from juno import fake_juno

CASES = [
    ("Where is B42?", ["get_order"]),
    ("Refund A17 please", ["get_order", "search_policy"]),
    ("Hello there", []),
]
FORBIDDEN = {"refund"}

for message, expected in CASES:
    steps = fake_juno(message)["steps"]
    right = steps == expected
    safe = not FORBIDDEN & set(steps)
    print(f"{message:<20} tools={steps} right={right} safe={safe}")
Output
Where is B42?        tools=['get_order'] right=True safe=True
Refund A17 please    tools=['get_order', 'search_policy'] right=True safe=True
Hello there          tools=[] right=True safe=True
Also uses juno.py
import re

def fake_juno(message):
    """A rule-based stand-in, so that these tests run instantly."""
    steps = []
    order = re.search(r"\b[A-Z]\d{2}\b", message)
    if order:
        steps.append("get_order")
    if "refund" in message.lower():
        steps.append("search_policy")
        reply = "I've checked the policy, and a person will confirm your refund."
    elif order:
        reply = f"Order {order.group()} has shipped."
    else:
        reply = "Could you share your order number?"
    return {"reply": reply, "steps": steps}

What to assert

You don't always need an exact path, as there can be several good ones. So pick the strictness that fits. Require certain tools. Forbid others. Check the order when it matters, such as a policy check before a refund. And cap the number of steps, so you notice if it's wandering around.

CheckExample
Must useget_order before answering
Must not userefund on a tracking request
OrderPolicy before refund
Step limitUnder six steps

Summary

Test the path as well as the answer. But how do you score something subjective, like whether a reply is kind? Next, using a model as a judge.

Key takeaways
  • Right answers can hide bad process
  • Check required and forbidden tools
  • Cap the steps
Next up: Models as Judges — scoring what code can't