Responsible AI & Agent Governance
Guardrails and controls · Prompt Shields · Task Adherence · safety evaluators · red teaming · tracing and audit · approvals and tool control
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Guardrails, controls and intervention points
A guardrail is a named collection of controls. Each control defines a risk to detect, the intervention points to scan, and the action to take. One guardrail can be applied to many models and many agents in a project. Content risks are flagged by Azure AI Content Safety classification models.
| Intervention point | Scans | Applies to |
|---|---|---|
| User input | The prompt sent to a model or agent | Models and agents |
| Tool call (preview) | The action and data the agent proposes to send to a tool | Agents only |
| Tool response (preview) | Content returned from a tool to the agent, before it reaches memory or the user | Agents only |
| Output | The final completion returned to the user | Models and agents |
| Blocking level (hate, sexual, self-harm, violence) | Blocks |
|---|---|
| Off | Nothing. Detection can still return annotations. Inputs can be turned off by all customers; outputs only by approved customers |
| Low | High-severity content only (least restrictive) |
| Medium | Medium and high severity (the DefaultV2 level for the four core-harm categories) |
| High | Low, medium and high severity (most restrictive) |
- Actions: Annotate (models only) or Annotate and block (models and agents). Core-harm filters and user prompt attack detection are on by default; document attack detection is off by default and must be enabled.
- Agent guardrail overrides the model's. Risks in an agent are detected by the guardrail assigned to the agent, not the one on its underlying model. Controls that don't fit models (tool call, tool response) are not run on models.
- Tool call and tool response controls need moderation support from the tool (for example Azure AI Search, Azure Functions, OpenAPI, Bing Grounding, Browser Automation). For other tools the controls don't take effect. Each intervention point adds roughly 50-100 ms of latency.
- Create a guardrail in the portal: Build, then Guardrails, Create Guardrail, add controls, assign agents and models, review. You need the Foundry Account Owner role or higher. Controls that can't be deleted (violence, hate, sexual, self-harm on input and output) are changed by overriding them.
- Hosted agents also support network egress controls (preview) in the same guardrail, limiting the destinations an agent can reach. These apply only to hosted agents.
- If you bring your own model behind an AI gateway, you are responsible for responsible-AI mitigations such as metaprompt and content filters.
Risk detection: Prompt Shields and Task Adherence
| Control | Detects | Where |
|---|---|---|
| User prompt attack (Prompt Shields) | Prompts that try to bypass system rules: change rules, conversation mockup, role-play, encoding. Formerly jailbreak risk detection | User input. On by default |
| Document / indirect attack (Prompt Shields) | Hidden instructions in documents, emails or web pages that try to hijack the session (cross-domain prompt injection, XPIA) | User input for models; also tool response for agents with supported tools. Off by default |
| Protected material | Copyrighted text (and code) in completions | Output |
| Task Adherence (preview) | Tool calls and responses that don't match the user's intent; signal to block or escalate to human-in-the-loop review | Agents and models |
- In Foundry, Prompt Shields blocking happens before the model processes the input. In the Azure AI Content Safety APIs, the API doesn't block or route content: your application decides what to do with the result.
- Prompt Shields don't decide whether content is harmful, accurate, grounded, compliant or on task. Use other controls for those risks.
- Task Adherence gives a signal for blocking downstream tool calls and escalating to human-in-the-loop (HITL) review.
Evaluators, safety evaluations and red teaming
Evaluators are scoring methods for quality, safety and reliability. Some are deterministic; AI-assisted evaluators use a judge model and can provide explanations. Foundry evaluations produce metrics and, when supported, explanations.
| Safety evaluator | Measures | Targets |
|---|---|---|
| Hate and unfairness, Sexual, Violence, Self harm | Harmful content; 0-7 severity, default threshold 3 (pass when score is at or below it) | Model and agents |
| Protected materials | Copyrighted text such as lyrics, recipes and articles | Model and agents |
| Code vulnerability | Generated code with security flaws (for example SQL injection) | Model and agents |
| Ungrounded attributes | Ungrounded inferences about personal attributes | Model and agents |
| Indirect attack (XPIA) | Whether the response fell for an indirect jailbreak | Model only |
| Prohibited actions (preview) | Behaviours that violate explicitly disallowed actions or tool uses | Agents only |
| Sensitive data leakage (preview) | Agent exposing sensitive information | Agents only |
- Safety evaluations report an aggregate defect rate (share of undesired content). They run on the hosted Foundry evaluation models, so unlike coherence or fluency they don't need a judge deployment you supply.
- Evaluate a single turn or a whole conversation. Run once in development, add to CI/CD, or set up recurring evaluation for production.
- The AI Red Teaming Agent uses Microsoft's PyRIT framework and the safety evaluators to scan automatically. Its key metric is Attack Success Rate (ASR). Agentic risks (prohibited actions, sensitive data leakage, task adherence) are available only in cloud red teaming. Only text-based scenarios are supported.
- Explanation tooling: evaluator output can include an explanation, stored in the
gen_ai.evaluation.explanationtrace attribute. Learn doesn't describe model-interpretability tools beyond this.
Auditing: traces, sensitive content and provenance
- Tracing captures inputs, outputs, tool usage, retries, latencies and costs of an agent run. It is built on OpenTelemetry; spans are single operations, nested to show the call stack, and attributes hold metadata. Traces are stored in Azure Monitor Application Insights.
- Server-side tracing is the recommended start: Foundry enables it after you connect Application Insights, with no code changes, for prompt agents, hosted agents and workflows. Traces are available for the past 90 days in the portal. Add client-side OpenTelemetry instrumentation for your own code.
- To query traces you need Log Analytics Reader on the connected Application Insights resource. For protected tables also assign Privileged Monitoring Data Reader.
- Tracing can capture prompts, outputs and tool arguments. Redact or mask personal data, secrets and credentials before they reach telemetry, and apply the same access controls and retention you use for logs.
- Route sensitive content to the dedicated AppGenAIContent table (register the
protectGenAISensitiveDataflag), mark the table protected (deny by default), and grant Privileged Monitoring Data Reader to authorized identities. The page names September 30, 2026 as the migration date for this routing. - Correlate evaluation run IDs with trace data so quality and performance are seen together. A correlation ID header set at an AI gateway lets you trace MCP requests later in logs.
- Provenance: the default safety policy for image generation models includes a content credentials control on completions. Content Safety doesn't independently verify the provenance of content submitted to Prompt Shields; your integration defines it.
Governing agent behavior: approvals and tool access
- Approval workflow for MCP tools: configure the tool with
require_approvalset toalways; the run pauses with an approval request showing the server, tool and arguments; you review and approve only the expected call. Continue by submitting anmcp_approval_responsein the same conversation. Require approval for high-risk operations, especially tools that write data or change resources, and log approvals and tool calls. - Restrict tools: set
allowed_toolsto a nonempty list. An empty list allows all tools the server exposes. Reviewallowed_tools, approval settings and permissions when the server's operator, tools or behavior change. - Untrusted input: treat tool descriptions, annotations and results from remote MCP servers as untrusted; they can carry indirect prompt injection. Validate tool output against a schema and require user approval before consequential actions.
- tool_choice controls calling:
auto(model decides),required(must call one or more tools),none(no tool calls). - AI gateway (Azure API Management): one governed entry point for authentication, rate limits, IP restrictions and audit logging for MCP tools. You must apply the policies in API Management. Typical policies: rate limiting, IP filtering, correlation ID.
- Foundry Control Plane gives fleet-wide visibility: enterprise guardrail policies, bulk remediation of noncompliant configurations, scheduled red teaming and drift monitoring, and Defender and Purview alerts.
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Enable the dedicated table for sensitive trace content | az feature register --namespace Microsoft.Insights --name protectGenAISensitiveData | - |
| Install client-side tracing packages (Python) | pip install azure-ai-projects opentelemetry-sdk azure-core-tracing-opentelemetry | - |
Exam Tips
Tick each tip once you can answer it without looking.
“Block jailbreak-style prompts before the model sees them” → Guardrail control: user prompt attack (Prompt Shields) at user input, action Annotate and block.. Trap: Output scanning happens after the model has produced a completion.
“Agent calls a tool; scan retrieved tool content for hidden instructions” → Indirect (document) attack control at the tool response intervention point.. Trap: User input doesn't see tool responses.
“Model guardrail is strict but its agent is more permissive” → The agent's own guardrail fully overrides the model's guardrail.. Trap: Assuming the model guardrail still applies to the agent.
“Tool call or tool response control does nothing for a custom tool” → The tool must support moderation; only listed tools do.. Trap: Assuming every tool is scanned.
“Document attack detection isn't blocking anything on a new deployment” → It's off by default; enable it in the guardrail controls.. Trap: User prompt attack detection is on by default, document attack is not.
“Need to edit the violence control on user input” → Override the control with the same risk; those controls can't be deleted.. Trap: Deleting and re-adding it.
“Agent's tool call doesn't match what the user asked” → Task Adherence: block the tool call or escalate to human-in-the-loop review.. Trap: Prompt Shields don't judge whether a request is on task.
“Which safety evaluator is model-only, not for agents” → Indirect Attack (XPIA).. Trap: Prohibited actions and sensitive data leakage are agents only.
“Safety evaluator score is 3 with default settings” → Pass: pass when the score is less than or equal to the threshold (default 3) on the 0-7 scale.. Trap: Treating a score equal to the threshold as a fail.
“Automated adversarial scan with Attack Success Rate” → AI Red Teaming Agent (PyRIT-based); agentic risks need cloud red teaming.. Trap: Running agent risk categories in a local scan.
“Trace data contains prompts with personal data” → Redact before telemetry; route to the protected AppGenAIContent table and grant Privileged Monitoring Data Reader only to those who need it.. Trap: Log Analytics Reader alone doesn't read protected content; Privileged Monitoring Data Reader is needed in addition.
“Why did the agent call that tool? Find the step that failed” → Traces: spans per operation, stored in Application Insights; start with server-side tracing.. Trap: Evaluators score outputs; traces show each step.
“MCP tool that writes data must get a human check” → require_approval set to always; review server, tool and arguments, then send the approval response; log it.. Trap: allowed_tools limits which tools exist, it doesn't ask a human.
“Limit an MCP server to two of its tools” → allowed_tools with exactly those names (a nonempty list).. Trap: An empty list allows all tools.
“Central rate limits and audit logging for agent MCP tools” → AI gateway on API Management; apply the policies in API Management.. Trap: Changing the MCP server or agent code; the gateway enforces the policies without it.
“Groundedness detection (preview) in a content filter” → Retires April 30, 2027: plan to use Foundry evaluation or your own grounding validation.. Trap: Groundedness isn't a control agents support in guardrails.
Sources
- Guardrails and controls overview
- How to configure guardrails and controls
- Intervention points and controls
- Task Adherence (preview)
- Prompt Shields in Foundry
- Default safety policies
- Risk and safety evaluators
- AI Red Teaming Agent
- Evaluation in Foundry
- Observability in generative AI
- Agent tracing overview
- Set up tracing for agents
- Restrict access to sensitive content in traces
- Connect to MCP servers
- Tool best practices
- Govern MCP tools with an AI gateway
- Set up permissions for evaluation workflows
- Foundry Control Plane
- Bring your own model to Foundry Agent Service
Checked against Microsoft Learn on November 13, 2026.