Agent Optimizer is currently in preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
The optimization workflow
Optimizing an agent follows a repeatable path. Each step links to the article that covers it in detail:- Prepare your agent. Add the optimization package and a baseline configuration so the optimizer can read and improve your agent. See Make your agent optimizer-ready.
- Create an evaluation dataset. Define the tasks and criteria the optimizer scores against. See Create an evaluation dataset and evaluators.
- Run the optimizer. Start an optimization run and choose which targets and models to explore. See Optimize agent instructions, skills, tools, and models.
- Review the results. Compare candidate scores against your baseline and pick the best one. See Understand optimization results.
- Apply and deploy. Promote the winning candidate to your agent’s configuration and redeploy. See Deploy the winner.
How the agent optimizer works
The agent optimizer runs a closed-loop evaluation and improvement cycle:- Evaluate the baseline. The optimizer invokes your agent against a dataset of tasks and scores each response against criteria you define or a built-in default set. The baseline is your agent’s score before any changes.
- Generate candidates. The optimizer produces alternative configurations called candidates—rewritten instructions or discovered skills—designed to improve scores.
- Evaluate candidates. The optimizer tests each candidate against the same dataset.
- Rank and recommend. The optimizer ranks results by composite score, a value between 0.0 and 1.0 that represents aggregate performance, and marks the best candidate with ★. You then apply and deploy the winner.
load_config() returns your baseline normally and supplies optimized configuration automatically during and after a run - no feature flags or conditional logic.
Optimization targets
An optimization target is a specific aspect of your agent’s configuration that the optimizer can improve. The optimizer runs all applicable targets in a single run and automatically activates each one based on your baseline configuration andeval.yaml settings.
To set up these baseline inputs, see Make your agent optimizer-ready. To run and configure each target, see Optimize agent instructions, skills, tools, and models.
Models
The agent optimizer uses two models during an optimization run. Both must be deployed in your Foundry project.
The eval model runs once per task per candidate. It reads the agent’s response and each criterion, then returns a binary score. The optimization model analyzes baseline results and generates improved candidates across the configured targets (instructions, skills, tools, and models). Because it reasons over the full dataset, a more capable optimization model typically produces better candidates.
You specify these models in
eval.yaml or with CLI flags, and optimization_model is required. For configuration steps, see Choose the eval and optimization models.
Understand optimization results
This section explains the results table, how the composite score is computed, and how to interpret improvements. After an optimization run completes, you see a results table:Results table columns
The ★ marks the candidate with the highest composite score. This is the recommended candidate to deploy.
How scores are computed
Each evaluator in your dataset produces a raw score for the agent’s response. The optimizer processes these scores to produce the composite score shown in results:- Rescale: Each evaluator’s raw score is rescaled to 0–1.
- Flip if needed: If an evaluator is configured so that lower is better, the score is flipped so that all evaluators use “higher is better” semantics.
- Average: The rescaled scores across all evaluators and tasks are averaged to produce the composite score.
Interpret score improvements
Token trade-offs
Optimized instructions are often longer and more detailed, which can increase response token usage. Consider these factors:- Whether the token increase is proportional to the score improvement
- Whether the cost increase fits your budget
- Whether responses are unnecessarily verbose or adding value with the extra length
Limitations and availability
- The agent optimizer is available in all regions where hosted agents are available, except Norway East.
- The agent optimizer is supported for hosted agents that use the Responses protocol.