Microsoft.AgentGovernance.Extensions.Microsoft.Agents
4.0.0
Prefix Reserved
dotnet add package Microsoft.AgentGovernance.Extensions.Microsoft.Agents --version 4.0.0
NuGet\Install-Package Microsoft.AgentGovernance.Extensions.Microsoft.Agents -Version 4.0.0
<PackageReference Include="Microsoft.AgentGovernance.Extensions.Microsoft.Agents" Version="4.0.0" />
<PackageVersion Include="Microsoft.AgentGovernance.Extensions.Microsoft.Agents" Version="4.0.0" />
<PackageReference Include="Microsoft.AgentGovernance.Extensions.Microsoft.Agents" />
paket add Microsoft.AgentGovernance.Extensions.Microsoft.Agents --version 4.0.0
#r "nuget: Microsoft.AgentGovernance.Extensions.Microsoft.Agents, 4.0.0"
#:package Microsoft.AgentGovernance.Extensions.Microsoft.Agents@4.0.0
#addin nuget:?package=Microsoft.AgentGovernance.Extensions.Microsoft.Agents&version=4.0.0
#tool nuget:?package=Microsoft.AgentGovernance.Extensions.Microsoft.Agents&version=4.0.0
Microsoft.AgentGovernance.Extensions.Microsoft.Agents
Public Preview companion package for Microsoft.AgentGovernance that makes it easy to hook the real microsoft/agent-framework .NET pipeline exposed through Microsoft.Agents.AI into AGT governance.
Install
Run dotnet add package from the directory that contains your .csproj. If you're elsewhere, pass the project path explicitly:
dotnet add YourApp.csproj package Microsoft.AgentGovernance
dotnet add YourApp.csproj package Microsoft.AgentGovernance.Extensions.Microsoft.Agents
In Visual Studio Package Manager Console, use:
Install-Package Microsoft.AgentGovernance
Install-Package Microsoft.AgentGovernance.Extensions.Microsoft.Agents
Make sure the correct app is selected in the Default project dropdown. Typing the package name by itself at the prompt fails because PowerShell treats it as a command.
dotnet add package Microsoft.AgentGovernance
dotnet add package Microsoft.AgentGovernance.Extensions.Microsoft.Agents
What this package does
This package does not create a Microsoft Agent Framework agent for you. It assumes you already have a real Microsoft.Agents.AI AIAgent or AIAgentBuilder, then attaches AGT governance middleware around it.
The integration surface is:
AgentFrameworkGovernanceAdapterAgentFrameworkGovernanceOptionsAIAgentBuilder.WithGovernance(...)AIAgent.WithGovernance(...)
OSS expectations
- wraps an existing MAF agent or builder; it does not replace the MAF runtime
- translates MAF messages and function invocations into AGT policy/audit inputs
- keeps limitations explicit: function middleware only works when the underlying MAF pipeline supports function invocation middleware
- stays intentionally thin so MAF applications can share one governance hook instead of copying custom translation code
Integration options
This package supports two equally valid ways to wire AGT into a real MAF agent:
- Hook option - call
WithGovernance(...)on an existingAIAgentorAIAgentBuilder - Governance middleware option - create an
AgentFrameworkGovernanceAdapterexplicitly and reuse it anywhere you need the run/function middleware bridge
Hook option
using AgentGovernance;
using AgentGovernance.Extensions.Microsoft.Agents;
using Microsoft.Agents.AI;
var kernel = new GovernanceKernel(new GovernanceOptions
{
PolicyPaths = new() { "policies/loan-governance.yaml" },
EnablePromptInjectionDetection = true,
});
AIAgent agent = GetYourExistingMafAgent();
var governedAgent = agent.WithGovernance(
kernel,
new AgentFrameworkGovernanceOptions
{
DefaultAgentId = "did:agentmesh:loan-processor",
EnableFunctionMiddleware = true,
});
Governance middleware option
Construct the adapter explicitly when you want a reusable governance middleware object:
var adapter = new AgentFrameworkGovernanceAdapter(
kernel,
new AgentFrameworkGovernanceOptions
{
DefaultAgentId = "did:agentmesh:loan-processor",
EnableFunctionMiddleware = true,
});
var governedBuilder = agent.AsBuilder().WithGovernance(adapter);
var governedAgent = governedBuilder.Build();
This makes the MAF-to-AGT middleware bridge explicit while still using the same WithGovernance(...) extension point to attach it.
Hook points
Run middleware via
AgentFrameworkGovernanceAdapter.RunAsync(...)- evaluates message input against AGT policy
- emits AGT audit events
- returns a blocked
AgentResponsewhen denied
Function middleware via
AgentFrameworkGovernanceAdapter.InvokeFunctionAsync(...)- maps MAF tool calls into
GovernanceKernel.EvaluateToolCall(...) - sets
FunctionInvocationContext.Terminate = truewhen denied - returns a blocked tool result payload
- maps MAF tool calls into
Important constraint
EnableFunctionMiddleware = true only works for MAF agents backed by a function-calling pipeline that supports function invocation middleware (for example agents using a FunctionInvokingChatClient-compatible stack).
If you only need message/run governance, set:
EnableFunctionMiddleware = false
That keeps the adapter on the run middleware path only.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.AgentGovernance (>= 4.0.0)
- Microsoft.Agents.AI (>= 1.6.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Microsoft.AgentGovernance.Extensions.Microsoft.Agents:
| Repository | Stars |
|---|---|
|
foxminchan/BookWorm
The practical implementation of Aspire using Microservices, AI-Agents
|