Safety Evaluations, Tracing and Auditing
30-second answer
Use evaluators to score answers: quality (groundedness, relevance, coherence), safety (violence, hate and unfairness, self-harm, sexual, protected material) and agent evaluators (intent resolution, tool call accuracy, task adherence). Run the AI red teaming agent to attack the app before launch and report an attack success rate. Evaluator results include a reason, which gives explanations. For auditing, turn on tracing to Application Insights so every model call, tool call and approval is recorded, keep provenance metadata (source documents, model version, who approved) and use approval workflows for risky actions.
Simulate it » No Azure account neededExam objective: 1.4.2 Apply responsible AI instrumentation, including evaluators, safety evaluations and explanation tooling. 1.4.3 Implement auditing through trace logging, provenance metadata and approval workflows. (Skills measured as of April 16, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Build ➜ Evaluations</strong> and start a new evaluation.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Build ➜ Evaluations and start a new evaluation.
- Pick a test dataset and evaluators: quality, agent behaviour and risk and safety. AI-assisted evaluators use a judge model.
- Read each score. Tool call accuracy is under its threshold: open the failing rows to see which tool it picked wrongly.
- The AI red teaming agent (built on PyRIT) sends attacks with strategies like Base64 and character flips. Base64 got through 5% of the time, so tighten the guardrail and re-scan.
- A trace (OpenTelemetry, stored in Application Insights) shows the source documents, the tool call, who approved it and when. That's your audit trail.
- Provenance: the trace links the answer to its citations, the agent version and the model deployment. Keep it with the evaluation run that approved that version.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Evaluate, red team and trace
Evaluators score answers: groundedness, relevance, coherence, safety, and agent ones like tool call accuracy and task adherence. The AI red teaming agent attacks before launch. Traces in Application Insights record every model call, tool call and approval for audit.
🤔 What happens if…
Read this tour as text
- Pick the right model or tool. A router in your app sends each job to the cheapest thing that does it well: a reasoning model for multistep problems, a small language model for high-volume labelling, a multimodal model for photos, and a Foundry Tool such as Content Understanding for invoices.
- Where an agent gets its facts. Curated company content lives in a Foundry IQ knowledge base on Azure AI Search. Files a user drops into the chat go to file search. What the agent learns about the user across sessions goes to memory (user profile, chat summary).
- Resource, projects and deployment types. One Foundry resource holds deployments, networking and keys. Projects inside it isolate teams. Global deployments may process anywhere, Data Zone stays in the EU or US zone, Standard stays in one region. The standard agent setup keeps threads, files and vectors in your own Cosmos DB, Storage and AI Search.
- Configure deployments and agent versions. A deployment pins a model, a model version, a deployment type, capacity (TPM) and a guardrail. An agent gets a new version every time you change it; the endpoint serves the version you choose, so you can roll back.
- CI/CD with an evaluation gate. The agent definition, prompts and Bicep live in Git. The pipeline signs in with workload identity federation (no secret), runs an evaluation on a test set, and only then promotes from dev to test to prod projects.
- Quotas, 429s, spillover and budgets. Quota is tokens per minute per model, per region, per deployment type. Each deployment gets a slice; RPM comes with it. Go over and you get HTTP 429 with a retry-after header. Provisioned throughput can spill over to a standard deployment, and a cost control can stop a project at its token budget.
- Monitor models, agents and search. Azure Monitor metrics show requests, tokens, latency and errors. Application Insights holds traces, and continuous evaluation scores a sample of live answers for groundedness and safety. For Azure AI Search, watch indexer runs, document counts, search latency and throttled queries.
- Keyless and private. The app uses a managed identity and Microsoft Entra ID tokens, with the Foundry User role on the resource. Local (key) auth is turned off. Public network access is disabled and a private endpoint in your VNet is the only way in.
- Guardrails at four intervention points. A guardrail is a set of controls: a risk (hate, violence, prompt attacks, indirect attacks, protected material, PII), the intervention point (user input, tool call, tool response, output) and the action (annotate, or annotate and block).
- Evaluate, red team and trace. Evaluators score answers: groundedness, relevance, coherence, safety, and agent ones like tool call accuracy and task adherence. The AI red teaming agent attacks before launch. Traces in Application Insights record every model call, tool call and approval for audit.
- Govern what the agent may do. Give the agent only the tools it needs (allowed tools), make risky tools require approval from a human, let the tool call guardrail check what it sends, and limit where a hosted agent can connect with network egress controls.
Before launch, Contoso needs a guardrail that stops jailbreaks and hidden instructions, evidence that quality and safety hold up, and limits on what the agent may do. Build each, then test a refund through a human approval.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
The auditor asks why the agent refunded ₹3,200 last Tuesday, and nobody can answer.
😊 THE SOLUTION
Evaluate before release, red team it, and keep traces of every decision and approval.
- “It seemed fine in the demo”✓ Built-in evaluators on a test set
- Unknown attack surface✓ AI red teaming agent
- No record of decisions✓ Traces with tool calls and approvals
Start with a question
How do you prove the agent is safe, and how do you explain what it did last Tuesday?
Before launch, the risk team asks Asha for evidence. “It seemed fine in testing” isn’t evidence. After launch, a customer disputes a refund and an auditor asks who approved it and why.
Both questions have the same answer: measure before, record during. Evaluators and red teaming produce the numbers before launch. Traces and approvals produce the story afterwards.
Explain it like I’m 10
The technical explanation
Evaluators
| Family | Examples | Question answered |
|---|---|---|
| Quality | Groundedness, relevance, coherence, fluency, similarity | Is it correct, on topic and readable? |
| Safety | Violence, sexual, self-harm, hate and unfairness, protected material, code vulnerability | Does it contain harmful content? |
| Agent | Intent resolution, tool call accuracy, task adherence | Did the agent understand, act and finish correctly? |
| Custom | Your code or a prompt-based grader | Anything your policy needs |
Each result has a score and a reason, which is how you explain a low score to the team. Run evaluators on a dataset in the portal or from code:
from azure.ai.evaluation import evaluate, GroundednessEvaluator, RelevanceEvaluator
result = evaluate(
data="evals/support-cases.jsonl",
evaluators={"groundedness": GroundednessEvaluator(model_config), "relevance": RelevanceEvaluator(model_config)},
)
Put the same run in the pipeline as a gate and use a sampled version for continuous evaluation after release.
Red teaming
The AI red teaming agent generates adversarial prompts across risk categories (violence, hate and unfairness, sexual, self-harm), applies attack strategies (encoding, character flipping, jailbreak templates, multi-turn), sends them to your target and reports an attack success rate. Fix gaps with guardrail controls or prompt changes, then scan again.
Auditing: trace, provenance, approval
- Trace logging: connect Application Insights and enable tracing (OpenTelemetry). Each run records spans for the model call, tool calls, retrievals, guardrail results and approvals.
- Provenance metadata: store the retrieved source IDs, citations, model and prompt version, and the approver with each important answer or action.
- Approval workflows: risky tools pause for a human decision. The decision, approver and time go into the trace.
- Retention and access: traces contain user text. Set a retention period, limit who can read them, and mask personal data.
Architect level Why a model grades the model
Most quality evaluators use a language model as the judge, with a rubric and a reason. It’s cheaper than humans and consistent, and it has its own blind spots. Calibrate it by comparing its scores with a few hundred human-labelled examples, keep the judge model pinned, and use humans for high-stakes domains.
Real-world business scenario
Fabrikam Bank (fictional)
- The problem
- The risk committee wouldn't approve a loan-information agent without evidence of safety and traceable decisions.
- What they used
- An evaluation gate for groundedness, relevance and safety evaluators, an AI red teaming scan before each release, tracing to Application Insights with a one-year retention, and approval records for any account action.
- Why that choice
- The committee got measured numbers and attack results, and the audit team could replay any session from its trace.
- The result
- The agent was approved, and the first customer complaint was resolved from the trace in minutes.
When to use it and when not to
✓ Use it when…
- Answers or actions carry legal, financial or safety risk.
- You need evidence for a release decision or a regulator.
- Several people change prompts, tools or data.
✕ Think twice when…
- You trust one average score and skip red teaming.
- You keep traces forever with open access to personal data.
- You evaluate once at launch and never again.
↔ Alternatives to consider
- Human review panels for subjective or high-stakes judgments.
- Custom evaluators for company rules a built-in one doesn't know.
- Lightweight spot checks for a small internal prototype.
Test yourself with exercises
5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What does an evaluator do?
Model answer
It scores a response. For example, groundedness checks if the answer is supported by the retrieved text, and a safety evaluator checks for harmful content. I run them on a test set or on live samples, and I get a score and a short reason for each row.
Intermediate Why run red teaming if you already evaluate on a test set?
Model answer
A test set has the questions I thought of. Red teaming searches for the ones I didn't: jailbreaks, encoded prompts, multi-turn pressure. It gives an attack success rate I can lower by adding controls, then scan again.
Experienced developer What should an audit trail for an agent contain?
Model answer
Who asked, what the model saw, which documents were retrieved, every tool call with arguments, guardrail results, any human approval with the approver and time, and the model, agent and prompt versions. With tracing in Application Insights, a retention period and restricted access, an auditor can replay why a refund happened.
Scenario Compliance asks you to prove the loan agent doesn't give unfair advice. What do you present?
Model answer
Evaluation runs on a representative test set with fairness-related and safety evaluators, the red team report, the guardrail settings, and sampled traces with approvals. I'd also show the process: evaluators in the pipeline gate, so a regression blocks release. Evidence over time matters more than a single run.
Quick revision
Key points
- Evaluators score quality, safety and agent behaviour, with a reason for each score.
- Tool call accuracy and task adherence are agent evaluators. Groundedness needs context.
- The AI red teaming agent attacks before launch and reports an attack success rate.
- Tracing to Application Insights records model calls, tool calls and approvals for audit.
- Provenance metadata and approval workflows make decisions explainable and accountable.
Important terminology
- Evaluator
- A scorer for model or agent output. Built-in evaluators check quality, safety and agent behaviour. You can also write custom ones.
- Groundedness
- A quality score for how well an answer is supported by the retrieved context. Low groundedness means the model added unsupported claims.
- AI red teaming agent
- A Foundry tool, built on PyRIT, that automatically attacks your app with prompts across risk categories and attack strategies, then reports how many got through.
- Tool call accuracy
- An agent evaluator that checks whether the agent chose the right tools and passed the right arguments.
- Trace
- A recorded timeline of a run, with spans for model calls, tool calls, guardrail results and approvals. Stored in Application Insights.
- Provenance metadata
- Information that says where an answer came from: source documents, model and version, prompt version, time and the person who approved an action.
Common mistakes
- Running evaluators once and never in the pipeline or on live samples.
- Tracing without retention or access controls for the sensitive data inside traces.
- Treating a high average score as proof that no unsafe case exists.
Exam tips
- "Is the answer supported by the retrieved text" = groundedness.
- "Did the agent call the right tool with the right arguments" = tool call accuracy.
- "Attack the app before launch" = AI red teaming agent.
- "Replay why a decision happened" = trace logs with approvals.
Five quick revision questions
-
1.Which evaluator measures support from retrieved context?Show
Groundedness.
-
2.Which tool automatically attacks an app before launch?Show
The AI red teaming agent.
-
3.Where are traces stored?Show
In Application Insights.
-
4.What does an agent evaluator like tool call accuracy check?Show
Whether the right tools were called with the right arguments.
-
5.What metric does a red team scan report?Show
Attack success rate.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Govern Agent Behavior: Oversight, Constraints and Tool Access
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.