New Feature: IGuardrailProvider interface for policy-based function invocation control
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 領域
- ai, authorization, security
調査の方向性
既存のIAutoFunctionInvocationFilterパイプラインとその.NETおよびPythonのエントリポイントから始め、次にフィルターの登録方法と、呼び出しコンテキストおよび結果の表現方法を比較します。両方の言語で、許可、拒否、キャンセル、登録の動作を含むプロバイダー契約とフィルター統合が一貫して定義されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Feature Request
Title: New Feature: IGuardrailProvider interface for policy-based function invocation control
Is your feature request related to a problem?
Enterprise deployments of Semantic Kernel agents need a standardized way to enforce authorization policies on function invocations -- deciding whether a tool call should proceed based on caller identity, resource scope, risk level, or organizational policy. Today this is achievable through IAutoFunctionInvocationFilter, but each team builds ad-hoc policy logic inside their filter implementations with no shared contract for pluggable policy providers.
This gap has been raised repeatedly:
- #1409 -- "Guardrails for C#" (2023, closed with TypeChat redirect, no guardrail interface shipped)
- #5436 -- "Filters use cases to be supported before making feature non-experimental" (explicitly lists "Function Call Approval" as a core requirement)
- #10951 -- "Agent Invocation Filter" (2025, requesting filters that wrap agent invocations "allowing for scenarios like guardrails etc." for both .NET and Python)
- #13556 -- "Governance Policy Filter for Semantic Kernel" (2026, proposed a governance layer, closed and redirected to microsoft/agent-governance-toolkit)
- #12294 -- Handoff orchestration triggering OpenAI jailbreak guardrails (demonstrates the practical need for pre-invocation policy checks)
Describe the solution you'd like
A thin IGuardrailProvider interface that plugs into the existing filter pipeline. It separates the policy decision (should this call proceed?) from the filter mechanics (intercepting the pipeline).
C# (.NET)
namespace Microsoft.SemanticKernel;
/// <summary>
/// Provides policy-based authorization decisions for function invocations.
/// Implementations are registered with the Kernel and consulted by a
/// built-in AutoFunctionInvocationFilter before each tool call.
/// </summary>
public interface IGuardrailProvider
{
/// <summary>
/// Evaluates whether a function invocation should proceed.
/// </summary>
Task<GuardrailDecision> EvaluateAsync(
GuardrailContext context,
CancellationToken cancellationToken = default);
}
public sealed class GuardrailContext
{
public KernelFunction Function { get; init; }
public KernelArguments Arguments { get; init; }
public AutoFunctionInvocationContext InvocationContext { get; init; }
/// <summary>Optional caller identity for multi-tenant scenarios.</summary>
public ClaimsPrincipal? Principal { get; init; }
}
public sealed class GuardrailDecision
{
public bool IsAllowed { get; init; }
public string? Reason { get; init; }
public static GuardrailDecision Allow() => new() { IsAllowed = true };
public static GuardrailDecision Deny(string reason) =>
new() { IsAllowed = false, Reason = reason };
}
Python
from abc import ABC, abstractmethod
from dataclasses import dataclass
from semantic_kernel.filters.auto_function_invocation.auto_function_invocation_context import (
AutoFunctionInvocationContext,
)
@dataclass
class GuardrailContext:
function_name: str
plugin_name: str
arguments: dict
invocation_context: AutoFunctionInvocationContext
principal: dict | None = None # Caller identity claims
@dataclass
class GuardrailDecision:
is_allowed: bool
reason: str | None = None
@staticmethod
def allow() -> "GuardrailDecision":
return GuardrailDecision(is_allowed=True)
@staticmethod
def deny(reason: str) -> "GuardrailDecision":
return GuardrailDecision(is_allowed=False, reason=reason)
class GuardrailProvider(ABC):
@abstractmethod
async def evaluate(self, context: GuardrailContext) -> GuardrailDecision:
"""Return whether this function invocation should proceed."""
...
Integration with existing filters
The provider does not replace filters -- it plugs into them. A built-in GuardrailAutoFunctionInvocationFilter consults registered providers:
public class GuardrailAutoFunctionInvocationFilter : IAutoFunctionInvocationFilter
{
private readonly IEnumerable<IGuardrailProvider> _providers;
public async Task OnAutoFunctionInvocationAsync(
AutoFunctionInvocationContext context,
Func<AutoFunctionInvocationContext, Task> next)
{
var guardrailContext = new GuardrailContext
{
Function = context.Function,
Arguments = context.Arguments,
InvocationContext = context
};
foreach (var provider in _providers)
{
var decision = await provider.EvaluateAsync(guardrailContext);
if (!decision.IsAllowed)
{
context.Result = new FunctionResult(context.Function,
$"Blocked by guardrail: {decision.Reason}");
return; // skip next -- do not invoke function
}
}
await next(context);
}
}
Registration
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(...)
.Build();
kernel.AutoFunctionInvocationFilters.Add(
new GuardrailAutoFunctionInvocationFilter(
new MyOrgPolicyProvider(),
new AzureContentSafetyProvider()
));
Describe alternatives you've considered
- Raw
IAutoFunctionInvocationFilteronly -- Works today, but every team re-invents the allow/deny pattern. No shared contract means no ecosystem of pluggable providers. - External governance toolkit -- #13556 was redirected to microsoft/agent-governance-toolkit, but a lightweight in-kernel interface would enable third-party providers without requiring a separate toolkit dependency.
Why this fits Semantic Kernel's architecture
- Follows the existing filter pipeline pattern (
IAutoFunctionInvocationFilter,IFunctionInvocationFilter,IPromptRenderFilter) - Does not modify the filter contract -- composes on top of it
- Supports the "Function Call Approval" scenario explicitly called out in #5436
- Works for both .NET and Python with identical semantics
- Enables the agent-level guardrails requested in #10951
Additional context
A reference implementation of this provider pattern exists in APort Agent Guardrails, which enforces passport-based tool authorization policies for AI agents. The interface proposed here is deliberately provider-agnostic so that any policy backend (Azure Content Safety, OPA, custom rules, etc.) can plug in.
- 主要言語
- C#
- スター
- 28.8k
- フォーク
- 4.9k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 48
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/semantic-kernel のほかの issue
-
Python: Bug: ChatMessageContent.from_element drops AudioContent and BinaryContent into raw TextContent対応中かも @halcyon-past が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
microsoft/semantic-kernel#14824 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Python: Bug: Redis search returns None for every field that declares a storage_name, because RETURN lists the declared name対応中かも @wasim-builds が 9 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/semantic-kernel#14753 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23対応中かも @nightcityblade が 46 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
microsoft/semantic-kernel#14526 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)対応中かも @VANDRANKI が 48 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/semantic-kernel#14522 ·
メンテナーはふだん 3 日以内に返信
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI対応中かも @Laurianti が 48 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/semantic-kernel#14518 ·
メンテナーはふだん 3 日以内に返信
microsoft/semantic-kernel の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Support Flux ignore rules (drift detection ignore paths) in Microsoft.KubernetesConfiguration schemaオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Azure/azure-resource-manager-schemas#3921 ·
メンテナーはふだん 1 日以内に返信
-
text-align: justify is ignored in HTML to PDF conversion対応中かも @PrzemyslawKlys が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
asyncapi/modelina#2709 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信