Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 10 of 39
❮Prev Next❯

Safety Evaluations, Tracing and Auditing

Module 1: Plan & Manage ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Run evaluations, red team and read traces Run an evaluation, read the scores and open a trace.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Open <strong>Build ➜ Evaluations</strong> and start a new evaluation.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Open Build ➜ Evaluations and start a new evaluation.
    2. Pick a test dataset and evaluators: quality, agent behaviour and risk and safety. AI-assisted evaluators use a judge model.
    3. Read each score. Tool call accuracy is under its threshold: open the failing rows to see which tool it picked wrongly.
    4. 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.
    5. A trace (OpenTelemetry, stored in Application Insights) shows the source documents, the tool call, who approved it and when. That's your audit trail.
    6. 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.

    😟 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
    🛠️ Solved with: Evaluations, red teaming and tracing

    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

    FamilyExamplesQuestion answered
    QualityGroundedness, relevance, coherence, fluency, similarityIs it correct, on topic and readable?
    SafetyViolence, sexual, self-harm, hate and unfairness, protected material, code vulnerabilityDoes it contain harmful content?
    AgentIntent resolution, tool call accuracy, task adherenceDid the agent understand, act and finish correctly?
    CustomYour code or a prompt-based graderAnything 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

    1. Trace logging: connect Application Insights and enable tracing (OpenTelemetry). Each run records spans for the model call, tool calls, retrievals, guardrail results and approvals.
    2. Provenance metadata: store the retrieved source IDs, citations, model and prompt version, and the approver with each important answer or action.
    3. Approval workflows: risky tools pause for a human decision. The decision, approver and time go into the trace.
    4. 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

    Banking

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    You need a score that shows whether an answer is supported by the retrieved passages. Which evaluator should you use?

    Question 2

    Question 2 of 5

    Before launch, you want automated adversarial prompts sent to your app across risk categories and attack strategies. Which Foundry capability should you use?

    Question 3

    Question 3 of 5

    An auditor asks which tool an agent called, with what arguments, and who approved a refund, for a session last week.

    What should have been enabled?

    Question 4

    Question 4 of 5

    Which evaluator checks whether an agent selected the correct tools and passed correct arguments?

    Question 5

    Question 5 of 5

    Which practice makes a pipeline block a release that lowers safety quality?

    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. 1.Which evaluator measures support from retrieved context?Show

      Groundedness.

    2. 2.Which tool automatically attacks an app before launch?Show

      The AI red teaming agent.

    3. 3.Where are traces stored?Show

      In Application Insights.

    4. 4.What does an agent evaluator like tool call accuracy check?Show

      Whether the right tools were called with the right arguments.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.