ControlAgentNet.Guards
0.1.5
dotnet add package ControlAgentNet.Guards --version 0.1.5
NuGet\Install-Package ControlAgentNet.Guards -Version 0.1.5
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="ControlAgentNet.Guards" Version="0.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ControlAgentNet.Guards" Version="0.1.5" />
<PackageReference Include="ControlAgentNet.Guards" />
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 ControlAgentNet.Guards --version 0.1.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ControlAgentNet.Guards, 0.1.5"
#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 ControlAgentNet.Guards@0.1.5
#: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=ControlAgentNet.Guards&version=0.1.5
#tool nuget:?package=ControlAgentNet.Guards&version=0.1.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ControlAgentNet.Guards
Tool execution guards for ControlAgentNet agents.
Features
RiskDenyGuard- Block tools by risk levelToolAllowlistGuard- Only allow specific tools- Configurable order for guard execution
- Exemption support for risk-based guards
- FrozenSet for efficient lookups
- Zero external dependencies beyond Microsoft.Extensions.Options
- Composable and extensible
Installation
dotnet add package ControlAgentNet.Guards
RiskDenyGuard
Blocks tools that exceed a configurable risk threshold.
using ControlAgentNet.Guards;
using ControlAgentNet.Core.Descriptors;
builder.Services.AddRiskDenyGuard(opts =>
{
opts.MinimumDeniedRiskLevel = CapabilityRiskLevel.High;
opts.ExemptToolIds = new[] { "admin_tool", "safe_tool" };
opts.Order = 10;
});
Options
| Property | Default | Description |
|---|---|---|
MinimumDeniedRiskLevel |
High | Minimum risk level to block |
ExemptToolIds |
empty | Tools to exempt from blocking |
Order |
10 | Execution order |
ToolAllowlistGuard
Only allows specific tools to execute.
using ControlAgentNet.Guards;
builder.Services.AddToolAllowlistGuard(opts =>
{
opts.AllowedToolIds = new[] { "greeting", "search", "weather" };
opts.TreatEmptyAllowlistAsAllowAll = false;
opts.Order = 20;
});
Options
| Property | Default | Description |
|---|---|---|
AllowedToolIds |
empty | List of allowed tool IDs |
TreatEmptyAllowlistAsAllowAll |
false | Allow all if list is empty |
Order |
20 | Execution order |
Custom Guards
using ControlAgentNet.Core.Abstractions;
using ControlAgentNet.Core.Models;
public class RoleGuard : IToolGuard
{
public int Order => 5;
public Task<ToolGuardDecision> EvaluateAsync(
ToolExecutionRequest request,
CancellationToken ct)
{
if (!user.IsAdmin)
return Task.FromResult(ToolGuardDecision.Deny("Admin only"));
return Task.FromResult(ToolGuardDecision.Allow());
}
public Task<bool> CanExecuteAsync(
string toolName,
IDictionary<string, object?>? arguments,
string conversationId,
string userId,
CancellationToken ct)
=> Task.FromResult(true);
public string GetDenialReason(string toolName)
=> $"Tool '{toolName}' requires admin role.";
}
builder.Services.AddToolGuard<RoleGuard>();
Build
dotnet restore ControlAgentNet.Guards.slnx
dotnet build ControlAgentNet.Guards.slnx -c Release
dotnet test ControlAgentNet.Guards.slnx -c Release --no-build
dotnet pack ControlAgentNet.Guards.slnx -c Release -o artifacts/nuget
Versioning
- local builds:
0.1.5-dev - pull requests:
0.1.5-preview.<run_number> - pushes to
main:0.1.5-alpha.<run_number> - tags like
v0.1.5: exact stable package version0.1.5
See VERSIONING.md for the release flow.
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- ControlAgentNet.Core (>= 0.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ControlAgentNet.Guards:
| Package | Downloads |
|---|---|
|
ControlAgentNet.Guards.Policies
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.