Lesson 2 of 4 Securing Microsoft Foundry Workloads

Configuring Guardrails in Foundry

This lesson explains the structure of a guardrail, where it intervenes, and how assignment works.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe a guardrail and its controls.
  • Identify the intervention points.
  • Match a risk to an intervention point.
  • Explain how guardrails override.

What a guardrail is

A guardrail in Microsoft Foundry is a named collection of controls. Each control defines three things: a risk to detect, the intervention points at which to check for it, and the action to take. A single guardrail can be applied to many models and agents, so that a security team can define a standard and reuse it.

Guardrails address what a model says and what an agent does at each stage. They do not replace identity and network controls, because they examine content rather than access.

Intervention points

An agent interaction has more stages than a simple chat, and each one is a place where something can go wrong. The following table shows the four points.

Intervention pointApplies toWhat it examinesWhy it matters
User inputModels and agentsThe prompt that the user sendsStops direct attacks and harmful requests
Tool call (Preview)Agents onlyThe call that the agent plans to makeStops sensitive data from leaving through a tool
Tool response (Preview)Agents onlyWhat the tool returnsStops hidden instructions in retrieved content
OutputModels and agentsThe final responseStops harmful or sensitive content from reaching users

The tool response point is especially important for indirect prompt injection. When an agent fetches a web page or document that contains hidden instructions, this is the point at which they enter the conversation. A model deployment has no tools, which is why these two points apply to agents only.

The following diagram places the four intervention points in an agent interaction.

The four guardrail intervention points in an agent interaction. User input is checked before it reaches the model. The tool call point examines the call the agent plans to make, so sensitive data does not leave through a tool. The tool response point examines what the tool returns, which stops hidden instructions in retrieved content, known as indirect prompt injection. Output is checked before it reaches the user. Model deployments have no tools, so the two tool points apply to agents only.
Each point is a place where something can go wrong.
Match the pairs

Intervention points

Exam skills 3.1.9

Match each guardrail intervention point with the risk it stops.

Log in to try this activity Interactive activities are free with an account.

Risks

The following table shows the risks that a control can address, and whether each one applies to models, to agents, or to both.

RiskModelsAgents (Preview)What it does
Hate, Sexual, Self-harm, ViolenceYesYesBlocks harmful content at a level of Off, Low, Medium or High
User prompt attacksYesYesDetects direct jailbreak attempts
Indirect attacksYesYesDetects instructions hidden in documents and other content
Spotlighting (Preview)YesNoMarks untrusted input so that a model can treat it as data
Protected materialYesYesDetects known text and code
Groundedness (Preview)YesNoChecks whether a response is supported by its source
PII (Preview)YesYesDetects personally identifiable information
Task adherence (Preview)YesYesDetects when actions depart from the intended task

Two actions are available. Annotate records a finding without blocking, and it applies to models only. Annotate and block records the finding and stops the content. The groundedness feature for Azure OpenAI retires on 30 April 2027, so check Microsoft Learn before designing around it.

True or false

Guardrail risks and actions

Exam skills 3.1.9

Check which guardrail risks and actions apply to models and agents.

Log in to try this activity Interactive activities are free with an account.

Assignment

How a guardrail reaches a model or agent decides what actually protects a workload, and this is frequently tested.

  • Models receive the default guardrail Microsoft.DefaultV2 unless another one is assigned.
  • If no custom guardrail is assigned to an agent, it inherits the guardrail of its model deployment.
  • If an agent has its own guardrail, that guardrail fully overrides the model's guardrail. They do not combine.
  • One guardrail can be applied to many models and agents.
  • Guardrails apply only to agents built in Foundry Agent Service, not to other agents registered in the Foundry control plane.

Override, not merge

Because an agent's guardrail overrides rather than adds to the model's guardrail, assigning a narrow custom guardrail to an agent can silently remove protections that it used to inherit. Include every control that the agent needs.

Scenario questions

Which guardrail applies?

Exam skills 3.1.9

Work out which guardrail protects each workload.

Log in to try this activity Interactive activities are free with an account.

Designing a guardrail

A strong agent guardrail places controls at each relevant point. Prompt attacks are checked on user input, indirect attacks on tool responses, PII on tool calls and outputs, and task adherence where an agent might wander from its purpose. Hosted agents can also have egress controls, in preview, to limit where they can connect, and these are configured in the same guardrail.

Start strict for agents with tools, test with representative content, and adjust where false positives occur. Log blocked events, since a surge can indicate an attack. Guardrails reduce risk but do not remove it, so continue to apply least privilege to the agent's identity.

Worked example

A guardrail for a research agent

A Foundry agent reads pages from the public web and can email reports. The security team is concerned about hidden instructions in web pages and about personal data leaving through email. The agent's model deployment already has a strict custom guardrail. A developer proposes assigning a new guardrail to the agent, with only a PII control. What should you advise?

The concern about hidden instructions calls for the indirect attacks risk at the tool response point. Personal data leaving through email calls for PII at the tool call point. The proposal is unsafe as it stands: an agent's guardrail fully overrides the model's, so a PII-only guardrail would remove all of the existing protections.

Include the model's existing controls in the agent's guardrail, along with these additions. Checking only user input would miss both threats, since neither comes from the user.

Check yourself

Why does the tool call intervention point not apply to a model deployment?

Show answer

A model on its own has no tools. Tool calls occur only in agents.

Exam Tips

Remember for the exam

  • A control combines a risk, intervention points and an action.
  • Tool call and tool response points apply to agents only.
  • Use tool response to catch indirect prompt injection.
  • An agent's guardrail fully overrides the model's guardrail.