Skip to course content
Free LLMOps course

LLMOps for Reliable AI Applications

Unit 06.00: Judging the path, not just the answer

An agent can reach the right answer by a path you would never approve.

Same answer, three very different runs

Correct output tells you nothing about how many tools ran, in what order, or whether anything was acted on prematurely.

The code compares three runs that all produced a correct answer.

RUNS = [
    {"id": "r1", "answer_ok": True,
     "path": ["read_account", "check_policy", "respond"]},
    {"id": "r2", "answer_ok": True,
     "path": ["read_account", "read_account", "read_account", "check_policy",
              "respond"]},
    {"id": "r3", "answer_ok": True,
     "path": ["issue_refund", "read_account", "respond"]},
]
EXPECTED = ["read_account", "check_policy", "respond"]
for r in RUNS:
    exact = r["path"] == EXPECTED
    extra = len(r["path"]) - len(EXPECTED)
    acted_early = r["path"][0] == "issue_refund"
    print(f"{r['id']}  answer_ok={r['answer_ok']}  path_ok={exact!s:5} "
          f"extra_steps={extra}  {'ACTED BEFORE CHECKING' if acted_early else ''}")

# All three produced a correct answer. `r2` cost three times the tool calls and
# `r3` issued a refund before reading the account. Scoring the answer alone
# rates all three identically.

r2 used three times the tool calls for the same result - a cost problem invisible in the output. r3 issued a refund before reading the account, which is a control failure that happened to produce a correct answer this time.

Answer-only scoring rates all three identically. That is the argument for trajectory evaluation: for agents, the path is part of the behaviour you are trying to guarantee.

The mistake this prevents

The mistake is evaluating agents the way you evaluate a chain. A chain's path is fixed and its output is the whole behaviour. An agent chooses its path, so the path is a choice that can be wrong independently of the answer.

Takeaway

Score the trajectory as well as the answer. Correct output can come from a path that cost three times as much or acted before it checked.