Skip to main content
Evaluation is essential for ensuring your agent meets quality and safety standards before deployment. By running evaluations during development, you establish a baseline for your agent’s performance and can set acceptance thresholds, such as an 85% task adherence passing rate, before releasing it to users. In this article, you learn how to run an agent-targeted evaluation against a Foundry agent or hosted agent. You use a rubric evaluator generated from your agent’s context as the primary measure, and layer in built-in evaluators for content safety and other risks. Specifically, you:
  • Set up the SDK client for evaluation.
  • Generate a rubric evaluator tailored to your agent, and pair it with built-in evaluators.
  • Create a test dataset and run an evaluation.
  • Interpret results and integrate them into your workflow.
For general-purpose evaluation of generative AI models and applications, including custom evaluators, different data sources, and additional SDK options, see Run evaluations from the SDK.

Prerequisites

  • Python 3.8 or later.
  • A Foundry project with an agent or hosted agent.
  • An Azure OpenAI deployment with a GPT model that supports chat completion (for example, gpt-4o or gpt-4o-mini).
  • Foundry User role on the Foundry project.
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
Some evaluation features - including rubric generation, synthetic and trace-based dataset creation, and risk and safety evaluators - have regional restrictions. See Rate limits, region support, and enterprise features for evaluation for the full list.

Set up the client

Install the Foundry SDK and set up authentication:
Create the project client. The following code samples assume you run them in this context:

Choose evaluators

Evaluators score your agent’s responses. The recommended primary measure for agent evaluation is a rubric evaluator—a set of weighted scoring dimensions that an LLM judge applies to every response, so you can express the exact criteria that matter (for example, policy enforcement, tool usage accuracy, or communication clarity) and score consistently at scale. For details, see Rubric evaluators. Pair your rubric with additional evaluators to get full coverage of your evaluation scope: You can author a rubric by hand, or generate one from the agent’s context—its name, instructions, and tools. The following sample generates a rubric and prints its dimensions so you can review them before use.
For a complete runnable example, see sample_rubric_evaluator_generation_all_sources.py on GitHub. To hand-author a rubric instead, see sample_rubric_evaluator_manual.py.

Create a test dataset

Create a JSONL file with test queries for your agent. Each line contains a JSON object with a query field:
If you don’t have a hand-curated dataset, you can bootstrap one. Use Generate a synthetic evaluation dataset when you’re prelaunch or have low traffic, or Convert agent traces into evaluation datasets to build a dataset from real production traffic.
Upload this file as a dataset in your project:

Run an evaluation

When you run an evaluation, the service sends each test query to your agent, captures the response, and applies your selected evaluators to score the results. First, configure your testing criteria. Reference the generated rubric evaluator by name. Each entry uses data_mapping to point at fields in the test data and agent response, and initialization_parameters to pass evaluator settings:
  • {{item.X}} references fields from your test data, like query.
  • {{sample.output_items}} references the full agent response, including tool calls.
  • {{sample.output_text}} references just the response message text.
  • initialization_parameters={"deployment_name": <model>} supplies the judge model. Typically required for LLM judge evaluators. For per-evaluator parameters, see built-in evaluators.
To layer in built-in evaluators alongside the rubric, append entries with the same shape but evaluator_name="builtin.<name>". For example, add Violence (content safety) and Coherence (LLM judge quality):
Next, create the evaluation. An evaluation defines the test data schema and testing criteria. It serves as a container for multiple runs. All runs under the same evaluation conform to the same schema and produce the same set of metrics. This consistency is important for comparing results across runs.
Finally, create a run that sends your test queries to the agent and applies the evaluators:
This sample works for both prompt agents and hosted agents that use the responses protocol. For hosted agents that use the invocations protocol, the input_messages format is different — provide a freeform JSON object instead of the structured template. For details and code samples, see Hosted agent invocations protocol in the cloud evaluation guide.
To evaluate agent interactions that already occurred using traces from Application Insights, see Trace evaluation in the cloud evaluation guide.

Interpret results

Evaluations typically complete in a few minutes, depending on the number of queries. Poll for completion and retrieve the report URL to view the results in the Microsoft Foundry portal under the Evaluations tab:
Screenshot showing evaluation results for an agent in the Microsoft Foundry portal.

Aggregated results

At the run level, you can see aggregated data, including pass and fail counts, token usage per model, and results per evaluator:

Row level output

Each evaluation run returns output items per row in your test dataset, providing detailed visibility into your agent’s performance. Output items include the original query, agent response, individual evaluator results with scores and reasoning, and token usage:
The properties.dimension_scores array shows the per-dimension breakdown the LLM judge produced. Each dimension’s score is on a 1–5 scale. The top-level score is the weighted average of applicable dimension scores, normalized to a 0–1 range. For the full output schema, see Rubric evaluators.

Integrate into your workflow

Optimize and compare versions

Use evaluation to iterate and improve your agent:
  1. Run evaluation to identify weak areas. Use cluster analysis to find patterns and errors.
  2. Adjust agent instructions or tools based on findings.
  3. Reevaluate and compare runs to measure improvement.
  4. Repeat until quality thresholds are met.