guide·6 min read

How to evaluate agent trajectories, not just final answers

A correct answer can hide the wrong tool, wasted steps, ignored errors or unsafe actions. Evaluate the complete session path, find recurring behavior across runs and use the evidence to improve the agent.

the short answer

Capture the complete agent session, including prompts, model turns, tool calls, tool results, errors and the final response. Run code-based evaluations for exact trajectory facts and LLM-based evaluations for behavior that requires context. Then use Failproof audits to find recurring and previously unknown failure patterns across sessions, inspect the supporting traces, fix the prompt, model, tools or workflow, and keep the same evaluations running to verify that behavior improved.

Trace
Prompt, model turns, tool calls, results, errors and final response.
Known behavior
Code-based and LLM-based evaluations over the complete session.
Unknown patterns
Audits group recurring trajectory failures with trace evidence.
Improvement
Fix the agent, monitor the trend and add a tested policy only where needed.

Why the Final Answer Is Not Enough

An agent can produce the right answer through a path you would not want repeated. It may call the wrong tool and get lucky, retry an operation several times, ignore an error, skip required verification or perform an unnecessary write before correcting itself.

Trajectory evaluation examines how the agent worked, not only what it said at the end. This matters for reliability and for improvement: the path shows whether a failure belongs in the prompt, model, tool design, context, workflow or runtime boundary. Across many sessions, those paths reveal where the agent system itself needs to change.

Final resultTrajectoryInterpretation
CorrectEfficient and verifiedThe behavior to preserve
CorrectWasteful, risky or luckyA hidden failure the final answer misses
IncorrectReasonable pathOften a capability, data or instruction gap
IncorrectRepeated or unsafe pathA behavioral failure to investigate first

1. Capture the Complete Session Path

Send complete sessions to Failproof AI rather than logging only model inputs and outputs. The trace should preserve the original task, model turns, tool names and arguments, tool results, errors, retries and final response in order.

Use stable agent and environment identifiers. They let every evaluation, query, dashboard, alert and audit distinguish production from staging and compare behavior between versions without reconstructing cohorts later.

For supported coding-agent and chat harnesses, Failproof AI captures sessions through its hooks. Custom agents can send traces through the Python SDK and supported framework adapters.

2. Evaluate What Happened Along the Way

Use code-based evaluations for facts that can be read directly from the trace. Use LLM-based evaluations when the expected behavior depends on the task and context. Keep trajectory criteria separate from the final-outcome score so a correct result cannot hide an unsafe or inefficient path.

Trajectory questionEvaluation type
Did the agent exceed its tool-call or retry budget?Code-based
Did it repeat the same failed call?Code-based
Did it continue after a tool error without recovery?Code-based or LLM-based, depending on the tool
Did it select tools appropriate to the task?LLM-based
Did it verify the result before reporting success?Code-based when evidence is explicit; otherwise LLM-based
Did it follow the required workflow and constraints?LLM-based

Evaluation results appear beside the trace under Observe → evaluations. Re-evaluate individual sessions while refining a check, and backfill recent sessions once the evaluation is ready so you can see whether the behavior is isolated or widespread.

fp evals --since 24h --aggregate
fp evals --agent-id checkout-agent --aggregate
fp --json evals --aggregate --env production

3. Find Trajectory Failures You Did Not Define

A fixed evaluation can only measure behavior someone already thought to describe. Failproof audits analyze sessions together to find recurring and previously unknown patterns in traces, evaluation results and policy decisions.

Set an audit goal such as “find inefficient or risky paths taken by the production support agent” or “find sessions where the agent recovered poorly from tool failures.” Choose the agent, environment, time window and cadence. Findings group related sessions and include severity, analysis, affected traces, evidence queries and a recommended fix.

fp audits list
fp audits findings --status open --limit 20

Review several sessions behind each finding. One repeated call may come from a bad retry instruction; another may come from a slow or ambiguous tool response. The grouped evidence helps separate a recurring system problem from an unusual one-off run.

4. Query and Dashboard Agent Behavior

Use Analyze → Queries to examine trajectory behavior across the fleet. Queries are read-only SQL and can be saved as dashboard panels. Track measures such as tool calls per successful task, repeated-error rate, verification rate and the share of sessions that exceed a step budget.

The Failproof agent can turn an investigation question into an analysis. Inspect the result, save the useful query and use that stable definition for future comparisons.

fp agent ask "Which production agents repeat failed tool calls most often?"
fp agent ask "Compare verification rates by agent and environment over the last 30 days"
fp query run <query-id>

Dashboards show whether behavior is improving over time. Alerts can fire on evaluation scores, compound conditions, metric thresholds or saved SQL and route to email, Slack, a webhook or the dashboard.

5. Fix the Cause, Not Only the Failed Session

Use the trace evidence and audit recommendation to decide what to change. Common fixes include clarifying the task contract, reducing unnecessary context, improving a tool response, changing retry behavior, exposing a missing capability, selecting a different model or requiring explicit verification before completion.

Assign the finding as an issue and keep its evaluation, query and audit running after deployment. The change has worked when the original pattern disappears, outcome quality holds and a new failure mode has not replaced it.

Use Policies for Proven High-Risk Actions

Most trajectory failures should improve the agent rather than block it. A policy is appropriate when the evidence identifies an action that is clearly unsafe or outside an agent’s authority, such as writing to a protected path or executing a prohibited command.

Failproof AI can generate a policy draft from an issue. Backtest it against previous sessions, deploy it in observe mode and review false positives before enforcement. Keep evaluating the trajectory afterward: a denied action is safer, but repeated attempts still indicate that the agent needs to be fixed.

FAQ

What is an AI agent trajectory?

An agent trajectory is the ordered path through a task: prompts, model turns, tool calls, tool results, errors, retries and the final response. It shows how the agent reached its outcome.

How is trajectory evaluation different from final-answer evaluation?

Final-answer evaluation scores the result. Trajectory evaluation scores the behavior that produced it, including tool selection, retries, error recovery, verification, efficiency and adherence to the required workflow.

Can Failproof AI find trajectory failures automatically?

Yes. Defined evaluations measure known behaviors, while Failproof audits analyze sessions across an agent and environment to group recurring and previously unknown failures into findings with trace evidence and recommended fixes.

Should every bad trajectory be blocked?

No. Most findings should lead to improvements in prompts, tools, context, models or workflows. Use a policy only for a proven high-risk action, and backtest and observe it before enforcement.

Get Started

Failproof AI is free to start. It finds recurring failure modes across agent sessions using code-based and LLM-based evaluations, groups the evidence into findings, and recommends fixes. Bring the eval suite you already have, alert the right owner when behavior drifts, and turn a tested fix into a policy that prevents the failure from recurring. See pricing for the tiers.

Sources

Products change; if a detail here is out of date, tell us at support@befailproof.ai.

  1. Failproof AI docs: Tracing
  2. Failproof AI docs: Evaluations
  3. Failproof AI docs: Audits
  4. Failproof AI docs: Queries