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
                    
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="Microsoft.AgentGovernance.Extensions.Microsoft.Agents" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.AgentGovernance.Extensions.Microsoft.Agents" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.AgentGovernance.Extensions.Microsoft.Agents" />
                    
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 Microsoft.AgentGovernance.Extensions.Microsoft.Agents --version 4.0.0
                    
#r "nuget: Microsoft.AgentGovernance.Extensions.Microsoft.Agents, 4.0.0"
                    
#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 Microsoft.AgentGovernance.Extensions.Microsoft.Agents@4.0.0
                    
#: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=Microsoft.AgentGovernance.Extensions.Microsoft.Agents&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.AgentGovernance.Extensions.Microsoft.Agents&version=4.0.0
                    
Install as a Cake Tool

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:

  • AgentFrameworkGovernanceAdapter
  • AgentFrameworkGovernanceOptions
  • AIAgentBuilder.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:

  1. Hook option - call WithGovernance(...) on an existing AIAgent or AIAgentBuilder
  2. Governance middleware option - create an AgentFrameworkGovernanceAdapter explicitly 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 AgentResponse when denied
  • Function middleware via AgentFrameworkGovernanceAdapter.InvokeFunctionAsync(...)

    • maps MAF tool calls into GovernanceKernel.EvaluateToolCall(...)
    • sets FunctionInvocationContext.Terminate = true when denied
    • returns a blocked tool result payload

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 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. 
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 (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
Version Downloads Last Updated
4.0.0 597 5/29/2026
3.7.0 436 5/18/2026
3.6.0 221 5/12/2026
3.5.0 180 5/8/2026
3.3.0 101 5/6/2026