THR860 · Theater
Make every agent better: The continuous optimization loop
Speakers: Vivek Bhadauria, Bhuwan Sahni
Microsoft’s player cannot open a video at a given time: once it plays, skip to the time shown.
What the session covers
Vivek Bhadauria and Bhuwan Sahni show how to build a continuous optimization loop for agents in Microsoft Foundry, using a sample Contoso Air support agent that runs on the managed Copilot harness. They explain why production agents fail silently and why adding more and more prompt rules is an anti-pattern. The demos cover agent insights clustering traces to find a lounge-policy gap, the agent optimizer generating and scoring prompt candidates with a 10% traffic experiment, annotating a production trace, and the "learn from past activity" optimization that generates a new skill from traces. The session ends with takeaways on OpenTelemetry tracing, evaluator design, A/B testing and the cost estimates shown for optimization jobs.
Best for: Agent developers and owners in Microsoft Foundry who want a practical, eval-driven workflow for finding and fixing quality problems in production agents.
New material starts at 06:43. The first six minutes are an introduction and a general explanation of why agents fail; at 06:43 the sample agent on the managed Copilot harness in Foundry is introduced and the outline of the loop begins.
Where to skip: Skip to 06:43. The core is the agent optimizer demo at 12:44 (evolutionary candidates and the 10% traffic experiment) and the "learn from past activity" demo at 19:16. The insights demo at 09:20 and the trace annotation at 16:21 are short and useful context. Watch the takeaways at 23:03 only for the A/B testing and cost notes.
Chapters (8)
- 00:02 Recap Depth 100 · Novelty 0/3
Introduction: from 'show me the code' to 'show me the evals'
Alex Jacobs introduces speakers Vivek Bhadauria and Bhuwan Sahni, who will share best practices for building an agent optimization loop with Microsoft Foundry. Vivek argues that in 2026 code and demos are cheap, so evaluations become the real signal of whether an agent delivers business value and can be iterated on using customer feedback.
- 02:02 Recap Depth 200 · Novelty 1/3
Why agents fail on day two and the prompt-patching anti-pattern
Vivek explains that building an agent (model, short instructions, tools, knowledge) is easy and reaching 70–80% accuracy is not hard, but production agents fail silently, non-deterministically (e.g. four out of six times) and on untested trajectories. He illustrates the anti-pattern of patching the instruction prompt with ever more emphatic rules ('always load the policy skill', 'never skip the calculator'), which causes overuse of tools and loss of common sense, leaving an agent that cannot be shipped.
- 06:43 Deep dive Depth 300 · Novelty 2/3
Sample airline support agent on the managed Copilot harness in Foundry
The sample Contoso Air support agent runs on the Microsoft Copilot harness – the same harness used under Microsoft 365 Copilot, GitHub Copilot and Copilot Cowork – offered in Foundry as a managed system. The agent has structured instructions, nine policy skills, Foundry IQ knowledge, OpenAPI tools for fees and flight status, and a shell Python tool for calculations; it correctly answers a delay question with $45 in meal vouchers. Vivek outlines the loop: traces, insights, evaluations, optimization and continuous learning.
- 09:20 Demo Depth 200 · Novelty 2/3
Demo: agent insights find a lounge-policy gap and suggest a skill fix
Bhuwan shows the baseline agent in Foundry (Copilot managed harness with shell only, policy skills, knowledge base, Contoso airline tool). A platinum member's question about bringing a guest to the lounge is answered poorly; instead of reading raw traces, agent insights cluster traces, flag that the agent was overly cautious on lounge-access policy, link to the exact trajectory and recommend a fix. He moves from insights to optimize, updates the loyalty tier skill, and the agent then answers correctly that the guest does not get the benefits.
- 12:44 Demo Depth 300 · Novelty 2/3
Demo: agent optimizer evolves prompt candidates and runs a 10% experiment
The agent optimizer takes a dataset of queries and can optimize for quality or cost by changing the model, suggesting a model router, rewriting tool descriptions or instructions; the dataset can be generated from bad traces or supplied, and rubrics are selected. It works like an evolutionary algorithm, batching the dataset, deriving candidates from each other and scoring them with evaluations; of four candidates, one improved the score by 10%. The candidate can be promoted directly or run as an experiment with 10% of traffic and traces compared against the original.
- 16:21 Demo Depth 200 · Novelty 2/3
Demo: annotating a production trace with correct answer and sources
Vivek shows a production question about whether a US passport holder collecting bags in the UK needs an ETA; the agent replies it is not in its policy, which is grounded but unhelpful. The corresponding trace is annotated as bad with the correct answer ('yes') and the authoritative policy source. He notes that traces can be human-annotated or evaluation-annotated and that the more accurate the annotations, the better.
- 19:16 Demo Depth 300 · Novelty 2/3
Demo: 'learn from past activity' optimization generates a new skill from traces
In the optimizer, Vivek chooses 'learn from past activity': it uses the last seven days of traces by default (37 here), optionally an evaluator, intelligently samples and groups traces by uniqueness and annotation status, and accepts steering instructions. The job finished in about five minutes, identified that the agent declines UK ETA questions, derived learnings from six related traces and generated a new skill. After adding it as the tenth skill, the agent answers that an ETA is required and cites the policy; such learnings can also add or edit skills about behaviour, not just knowledge.
- 23:03 Closing Depth 200 · Novelty 1/3
Takeaways: trace, find insights, define good, improve with proof; A/B testing and cost
Vivek's takeaway is to stop pleading with the prompt and build the loop: trace everything via OpenTelemetry to Azure Monitor or Foundry, derive insights from patterns, define good (LLM-as-judge, ground truth or deterministic code evaluators) and evolve evaluators to avoid benchmark-maxing, then improve with proof. He mentions Foundry recently launched A/B testing for safe production rollout, and Bhuwan adds that every optimization job shows an estimated cost and token usage.
Announcements (6)
-
Managed Copilot harness in Microsoft Foundry
Foundry hosts the Microsoft Copilot agent harness as a managed system to which you only supply tools, instructions, prompts and context.
Speaker’s quote (at 07:08)
„This is offered in Foundry as a managed system, so you don't have to host it yourself. You don't have to manage yourself.“
-
Agent insights in Microsoft Foundry
Analyzes all agent traces, identifies failing patterns and recommends prompt or skill changes with links to the affected traces.
Speaker’s quote (at 11:08)
„So the product agent insights, what it does is it looks at all of your traces. It will find which traces are good“
-
Agent optimizer in Microsoft Foundry
Automatically generates and evaluates improved agent candidates by changing model, model routing, tool descriptions or instructions against a dataset and rubrics.
Speaker’s quote (at 12:44)
„So agent optimizer is a mechanism where you can basically take a set of queries, you can have maybe 100 queries“
-
Learn from past activity optimization in Microsoft Foundry
Optimizes an agent from sampled real production traces, their annotations and optional evaluators, producing new or edited skills.
Speaker’s quote (at 19:16)
„I can learn from past activity. And this is really important. I'm not saying that what my goal is.“
-
A/B testing in Microsoft Foundry
Lets teams roll out agent changes to production safely by testing variants against each other.
Speaker’s quote (at 24:55)
„with recent Foundry, we have launched AB testing as well that you can push to production safely.“
-
Optimization job cost estimate in Microsoft Foundry
Shows the estimated cost and token consumption before running each optimization job.
Speaker’s quote (at 25:22)
„for every optimization job that you run on Foundry, Foundry also shows you estimated cost for it, what it will cost to run this job“
Demos (4)
-
An agent developer uses agent insights to find why the airline support agent mishandles lounge guest questions and fixes the relevant skill.
Steps (8)
- Open the baseline air support agent in Foundry built on the Copilot managed harness with only shell access enabled.
- Review the attached policy skills, knowledge base and Contoso airline tool.
- Ask the delay question and confirm the $45 meal voucher answer.
- Ask the platinum lounge guest question and observe the agent cannot answer about the guest.
- Open agent insights and review the generated insight about overly cautious lounge-access answers and its recommendation.
- Open the linked trace to see the exact trajectory and user view.
- Use the insights-to-optimize option and update the loyalty tier skill accordingly.
- Ask the platinum question again and verify the agent states that the guest does not get the benefits.
Prerequisites: A Foundry agent with tracing producing traces, policy skills and a knowledge base.
-
An agent developer improves the airline agent's quality with the agent optimizer and safely rolls out the best candidate.
Steps (9)
- Open agent optimizer for the agent.
- Select quality improvement as the optimization goal (cost is the alternative).
- Choose what the optimizer may change, here the agent instructions (options include model, model router and tool descriptions).
- Choose the dataset: generate one from bad traces or supply your own; here an own dataset is supplied and reviewed.
- Select the rubrics to improve on.
- Start the optimization job.
- Review the resulting candidates and their scores (one improved by 10%, one degraded, two unchanged).
- Either click Promote candidate or create an experiment routing 10% of calls to the new candidate and 90% to the original.
- Compare traces of both versions before moving to 100%.
Prerequisites: A Foundry agent, a dataset of queries or existing traces, and evaluation rubrics.
-
An agent owner captures feedback on a bad production answer by annotating its trace with the correct answer and sources.
Steps (4)
- Ask the production agent the UK ETA question and observe it declines to answer.
- Find the corresponding trace and open it.
- Inspect the user query and output in the trace.
- Open the annotations: the trace is marked bad, with the correct answer 'yes' and the authoritative policy listed as source.
Prerequisites: Production traces of the agent and human or evaluation annotations on them.
-
An agent owner lets the optimizer learn from annotated production traces to fix unhelpful UK ETA answers.
Steps (7)
- Open the optimizer and choose the 'learn from past activity' optimization.
- Keep the default time range of the last seven days (37 traces found) and optionally select an evaluator.
- Let it sample and group traces by uniqueness and annotation status.
- Enter steering instructions, here '…', and start the optimization.
- Open the completed job (about five minutes) and review the identified problem and learnings from the six related UK ETA traces.
- Review the generated skill and add it to the agent as the tenth skill.
- Ask the UK ETA question again and verify the agent says an ETA is required and cites the policy.
Prerequisites: Agent traces from production (optionally human or evaluation annotated) and optionally an evaluator.