Tracing and Evaluating Agent Decisions
This lesson explains how to monitor what agents decided at each step and evaluate whether those decisions were right, using agent tracing, agent evaluators and error analysis.
Learning outcomes
After completing this lesson, you will be able to:
- Describe what an agent trace records.
- Identify the agent evaluators and the fix each low score suggests.
- Assign failing conversations to causes with error analysis.
Tracing agents
When a Foundry project is connected to an Application Insights resource, Foundry Agent Service records each agent run as a trace with spans for model calls, tool calls (with arguments and results), retrieval and guardrail checks, including token counts and durations. The Foundry portal shows these traces per conversation and agent-level metrics such as run counts, errors, latency and token use. Applications add their own spans with OpenTelemetry so that a user request can be followed from the front end through the agent to back-end systems.
The following screenshot shows an agent trace in the Foundry portal: the agent span, the model calls and the tool call with their durations, and the input and output of the selected span.

Agent evaluators
Evaluating an agent is harder than evaluating a RAG answer, because a good final answer can hide a poor process. An agent might reach the right answer after calling the wrong tool twice, or give a polite refusal for a request it should have handled. Agent evaluators therefore score the steps as well as the outcome, and each one corresponds to a stage of the agent loop.
Intent resolution checks the first stage: did the agent understand what the user wanted? A low score usually means the instructions do not describe the requests the agent should handle, or the agent should ask a clarifying question.
Tool call accuracy checks the action stage: did the agent choose the right tools and pass correct arguments? A low score points to tool names, descriptions and schemas.
Task adherence checks whether the agent completed the task within its instructions and rules. A low score points to unclear or conflicting instructions.
The general evaluators, such as response completeness and groundedness, then judge the final answer. The following table lists the evaluators designed for agents.
| Evaluator | Question it answers | Typical fix when low |
|---|---|---|
| Intent resolution | Did the agent correctly identify what the user wanted? | Clarify instructions; ask clarifying questions |
| Task adherence | Did it follow its instructions and complete the task within its rules? | Tighten instructions and constraints |
| Tool call accuracy | Did it call the right tools with correct arguments? | Improve tool names, descriptions and schemas |
| Response completeness, groundedness | Is the final answer complete and supported? | Improve retrieval and instructions |
These evaluators run on agent conversations, including tool definitions and calls, either from a test dataset or from production traces. Continuous evaluation samples live conversations and tracks scores over time, and red teaming targets agents with adversarial inputs, including indirect attacks through tools.
Error analysis
Error analysis reviews failing conversations and assigns each to a cause: misunderstood intent, missing tool, wrong tool chosen, malformed arguments, tool error or timeout, retrieval found nothing, guardrail block, or the model ignored instructions. Counting causes shows where to invest: a cluster of malformed arguments points to schemas, while a cluster of tool timeouts points to the back-end service. After a fix, the same evaluations and traces confirm the improvement.
Where to invest?
An agent that gives up
Users report that a scheduling agent often says "I can't help with that" for valid requests. Task adherence scores are high, but intent resolution is low for requests that mention relative dates such as "next Tuesday afternoon".
Traces show that the agent never calls the calendar tool for these requests. The agent does not resolve relative dates into the tool's required ISO date format. Adding the current date to the instructions, describing the date parameter clearly, or adding a date-resolution function, then re-running intent resolution and tool call accuracy, addresses the cause.
Which evaluators measure agent behaviour?
Show answer
Intent resolution, task adherence and tool call accuracy.
Exam Tips
Remember for the exam
- Connect the project to Application Insights to trace agent runs, tools and tokens.
- Intent resolution, task adherence and tool call accuracy evaluate agent behaviour.
- Group failing conversations by cause before changing instructions or tools.