Measuring Remaining Risk with Safety Evaluation and Red Teaming
This lesson explains how Foundry measures the risk that remains after guardrails: risk and safety evaluators, automated adversarial testing and the explanations that help teams understand failures.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the risk and safety evaluators and what each measures.
- Describe how the AI red teaming agent automates adversarial testing.
- Identify explanation tooling for teams and users.
Risk and safety evaluators
Guardrails reduce risk, but they do not prove how much risk remains. A guardrail can be bypassed by an attack it does not recognize, and a model can produce borderline content that falls just below a blocking threshold. Before release, and after significant changes, a team therefore measures the remaining risk by running the application against adversarial inputs and scoring the responses with safety evaluators. The result is a defect rate per risk category, such as 0.5% of responses containing medium-severity violence, which can be compared with a release threshold in the same way that quality scores are.
The azure-ai-evaluation package and Foundry cloud evaluations include risk and safety evaluators that use a Microsoft-hosted safety evaluation service, so the team does not need to deploy its own judge model for them. The content harm evaluators score the same four categories that guardrails filter. Others detect whether the response followed instructions injected in its context, reproduced protected material, contained vulnerable code or made unsupported inferences about people. The following table lists them.
| Evaluator | Measures |
|---|---|
| Violence, Sexual, SelfHarm, HateUnfairness | Severity of harmful content in responses |
| ContentSafety (composite) | All four content harms in one evaluator |
| IndirectAttack | Whether the response followed injected instructions |
| ProtectedMaterial | Copyrighted text in responses |
| CodeVulnerability | Security vulnerabilities in generated code |
| UngroundedAttributes | Unsupported inferences about people, such as emotional state |
Each evaluator returns a label or severity, a score and a reason. The results of a run show defect rates per category, which are compared with release thresholds. Safety evaluation needs adversarial inputs, because ordinary test questions rarely trigger harmful output.
Safety evaluators
AI red teaming agent
The AI red teaming agent, built on the open-source PyRIT framework, automates adversarial testing. It generates seed attack prompts for chosen risk categories, transforms them with attack strategies such as Base64 encoding, character flipping, leetspeak or multi-turn escalation, sends them to the target model, agent or application callback, and evaluates the responses. The report gives the attack success rate overall, by risk category and by attack complexity, so the team can see which defences need strengthening. Automated red teaming complements, but does not replace, expert human red teaming.
Explanation tooling
Explanations help teams and users understand outputs. For teams, evaluator reasons explain each score, and traces show the retrieved documents, tool calls and intermediate outputs that produced an answer. For users, citations show the sources of a grounded answer, and disclosures explain that content is AI-generated. Microsoft's transparency notes document each model's and service's intended uses and limitations and inform an organization's impact assessment.
Explanations turn a failed evaluation into a fix. Suppose a safety run reports that 4% of responses scored as violent. The evaluator reasons show that most of them describe industrial accidents in safety manuals, and the traces show that those responses quoted retrieved manual text. The team can then decide whether the content is acceptable in context, adjust the guardrail's severity threshold for that application, or change retrieval, instead of guessing at the cause or lowering safety settings across the board.
Explain for whom?
Pre-release safety testing
A company will release a public chatbot next month. Leadership wants evidence of how often the bot can be manipulated into producing violent or hateful content, and which attack techniques work best.
Run the AI red teaming agent against the chatbot endpoint with the violence and hate-unfairness risk categories and several attack strategies, and review the attack success rate by strategy. Then strengthen the guardrail and instructions and repeat the scan. Running quality evaluators such as relevance on normal questions would not measure manipulation risk.
What does the AI red teaming agent report?
Show answer
The attack success rate by risk category, after running automated attack strategies against the application.
Exam Tips
Remember for the exam
- Measure harmful-content risk with safety evaluators on adversarial data.
- AI red teaming agent: automated attack strategies and attack success rate by category.
- Evaluator reasons and traces explain failures; citations explain answers to users.