GovUK.Dfe.AI.Agents.Guardrails
0.0.1-prerelease.316
Prefix Reserved
dotnet add package GovUK.Dfe.AI.Agents.Guardrails --version 0.0.1-prerelease.316
NuGet\Install-Package GovUK.Dfe.AI.Agents.Guardrails -Version 0.0.1-prerelease.316
<PackageReference Include="GovUK.Dfe.AI.Agents.Guardrails" Version="0.0.1-prerelease.316" />
<PackageVersion Include="GovUK.Dfe.AI.Agents.Guardrails" Version="0.0.1-prerelease.316" />
<PackageReference Include="GovUK.Dfe.AI.Agents.Guardrails" />
paket add GovUK.Dfe.AI.Agents.Guardrails --version 0.0.1-prerelease.316
#r "nuget: GovUK.Dfe.AI.Agents.Guardrails, 0.0.1-prerelease.316"
#:package GovUK.Dfe.AI.Agents.Guardrails@0.0.1-prerelease.316
#addin nuget:?package=GovUK.Dfe.AI.Agents.Guardrails&version=0.0.1-prerelease.316&prerelease
#tool nuget:?package=GovUK.Dfe.AI.Agents.Guardrails&version=0.0.1-prerelease.316&prerelease
GovUK.Dfe.AI.Agents.Guardrails
Makes sure every model deployment your GovUK.Dfe.AI.Agents agents use has an Azure AI Foundry guardrail. Before the model answers, Foundry blocks:
- harmful content (hate, sexual, violence, self-harm)
- jailbreak attempts
- instructions hidden in documents and tool output
- protected material
Set up
dotnet add package GovUK.Dfe.AI.Agents.Guardrails
"AiAgents": {
"Guardrails": {
"SubscriptionId": "<subscription id>",
"ResourceGroup": "<resource group>",
"Name": "briefing-guardrail",
"Deployments": [ "gpt-5.1" ]
}
}
builder.Services.AddAgents(builder.Configuration, agents => agents
.AddAgents(BriefingAgents.All)
.AddGuardrails());
Apply once, check everywhere
| Where | What to do | Role on the Foundry resource |
|---|---|---|
| A provisioning job | Call await guardrails.ApplyAsync(ct) (IFoundryGuardrailsService). This creates or updates the guardrail and assigns it to each deployment |
Cognitive Services Contributor |
| Every app | Nothing. At startup, the app checks each deployment has the guardrail and that it hasn't been weakened | Reader |
If a guardrail is missing or weakened, startup fails and says what's wrong. Set "RequireAtStartup": false to log a
warning instead. If Azure Resource Manager can't be reached, startup only logs a warning.
Settings
| Setting | Default | Purpose |
|---|---|---|
SubscriptionId, ResourceGroup |
Required | Where the Foundry resource is |
AccountName |
The resource in Foundry:Endpoint |
Set only if the deployments are on another Foundry resource |
Name |
Required | The guardrail's name in Foundry |
Deployments |
Required | Every model deployment your agents use |
BlockFrom |
Medium |
Lowest harm severity blocked in prompts and answers. Low blocks the most |
PromptShields |
true |
Blocks jailbreak attempts |
IndirectAttacks |
true |
Blocks instructions hidden in documents and tool output |
ProtectedMaterial |
true |
Blocks answers that reproduce protected text or code |
Blocklists |
None | Your own blocked terms and patterns (see below) |
RequireAtStartup |
true |
Fails startup when a deployment lacks the guardrail |
Authentication |
The default identity | A separate identity for Resource Manager (or agents.UseGuardrailsCredential(...) in code) |
Blocklists
Block your own terms, such as project code names or case reference formats:
"Blocklists": {
"case-references": { "Terms": [ "Project Falcon" ], "Patterns": [ "CASE-\\d{6}" ] }
}
ApplyAsync creates each blocklist, keeps its entries exactly as configured, and applies it to prompts and answers. The
startup check reports a blocklist that's detached or missing entries, showing counts only, never the entries
themselves. Load sensitive terms from Key Vault, not appsettings.json.
When Foundry blocks something
The run fails, and its inner exception is an AgentGuardrailException whose Stage is prompt or answer. The
dfe.ai_agents.guardrail.blocks metric counts each block. In parallel and sequential runs, the agent gets a fallback
result instead. Core does this reporting, with or without this package.
Not included
PII filtering: Foundry's PII filter needs a preview API, and this package uses GA APIs only. If you need it, turn it on in the Foundry portal; the startup check leaves it alone.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Azure.ResourceManager.CognitiveServices (>= 1.6.0)
- GovUK.Dfe.AI.Agents (>= 0.0.1-prerelease.316)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1-prerelease.316 | 37 | 10/9/2026 |
| 0.0.1-prerelease.289 | 36 | 10/9/2026 |
| 0.0.1-prerelease.263 | 37 | 10/9/2026 |
| 0.0.1-prerelease.238 | 37 | 10/9/2026 |
| 0.0.1-prerelease.214 | 36 | 10/9/2026 |
| 0.0.1-prerelease.191 | 33 | 10/9/2026 |
| 0.0.1-prerelease.169 | 35 | 10/9/2026 |
| 0.0.1-prerelease.148 | 38 | 10/9/2026 |
| 0.0.1-prerelease.128 | 36 | 10/9/2026 |
| 0.0.1-prerelease.109 | 44 | 10/7/2026 |
| 0.0.1-prerelease.91 | 40 | 10/7/2026 |
| 0.0.1-prerelease.74 | 48 | 10/6/2026 |
| 0.0.1-prerelease.58 | 57 | 10/5/2026 |
| 0.0.1-prerelease.44 | 54 | 10/5/2026 |
| 0.0.1-prerelease.31 | 47 | 10/5/2026 |
| 0.0.1-prerelease.20 | 59 | 10/2/2026 |
| 0.0.1-prerelease.10 | 56 | 10/2/2026 |