Table of Contents

Method WithPermissionPolicy

Namespace
LMKit.Agents
Assembly
LM-Kit.NET.dll

WithPermissionPolicy(ToolPermissionPolicy)

Sets the permission policy that governs which tools the agent may invoke.

public AgentBuilder WithPermissionPolicy(ToolPermissionPolicy policy)

Parameters

policy ToolPermissionPolicy

The permission policy to apply.

Returns

AgentBuilder

This builder instance for method chaining.

Examples

Restricting an agent to safe, read-only tools:

var agent = new AgentBuilder()
    .WithModel(model)
    .WithTools(t =>
    {
        foreach (var tool in BuiltInTools.GetAll())
            t.Register(tool);
    })
    .WithPermissionPolicy(new ToolPermissionPolicy()
        .AllowCategory("data", "text", "numeric", "utility", "security")
        .DenyCategory("io", "net")
        .SetMaxRiskLevel(ToolRiskLevel.Low))
    .Build();

Remarks

The permission policy controls tool access through allow/deny lists, category rules, risk-level gates, and approval requirements. It is stored on the ToolRegistry and evaluated before each tool invocation.

WithPermissionPolicy(Action<ToolPermissionPolicy>)

Configures the permission policy using a setup action.

public AgentBuilder WithPermissionPolicy(Action<ToolPermissionPolicy> configure)

Parameters

configure Action<ToolPermissionPolicy>

An action to configure the permission policy.

Returns

AgentBuilder

This builder instance for method chaining.

Examples

var agent = new AgentBuilder()
    .WithModel(model)
    .WithTools(t => { /* ... */ })
    .WithPermissionPolicy(policy =>
    {
        policy.Allow("calculator", "datetime", "websearch");
        policy.Deny("process", "smtp");
        policy.RequireApproval("filesystem", "http");
    })
    .Build();
Share