GovUK.Dfe.AI.Agents.Guardrails 0.0.1-prerelease.316

Prefix Reserved
This is a prerelease version of GovUK.Dfe.AI.Agents.Guardrails.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GovUK.Dfe.AI.Agents.Guardrails" Version="0.0.1-prerelease.316" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GovUK.Dfe.AI.Agents.Guardrails" Version="0.0.1-prerelease.316" />
                    
Directory.Packages.props
<PackageReference Include="GovUK.Dfe.AI.Agents.Guardrails" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
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"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GovUK.Dfe.AI.Agents.Guardrails@0.0.1-prerelease.316
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GovUK.Dfe.AI.Agents.Guardrails&version=0.0.1-prerelease.316&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=GovUK.Dfe.AI.Agents.Guardrails&version=0.0.1-prerelease.316&prerelease
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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