RiskLevel
Low / Medium / High / Critical. Set a ceiling per agent profile.
Every tool LM-Kit ships exposes machine-readable metadata: which
category it belongs to, whether it reads or writes, whether it
touches the network, what risk level it carries, whether it is
idempotent. ToolPermissionPolicy turns that metadata
into centralised access control, with allow rules, deny rules, risk
ceilings, and approval workflows.
Low / Medium / High / Critical. Set a ceiling per agent profile.
None, LocalRead, LocalWrite, NetworkRead, NetworkWrite, Irreversible.
Never / Conditional / Always. Suggested baseline per tool.
The moment you give an agent the file system, the network, and the shell,
you have to decide what it is allowed to do. "Read its way through the
docs" is fine. "Run rm -rf" is not. Without typed metadata
and a policy layer, that decision lives as code review folklore.
ToolPermissionAction covers the three useful outcomes. Default is approval-required for tools rated High or Critical risk.
Allow filesystem_*, deny filesystem_delete. Atomic tool naming makes wildcards a real security primitive.
AllowCategory("data", "text") + DenyCategory("io", "net") ships a safe-chat profile in two lines.
SetMaxRiskLevel(ToolRiskLevel.Low) rejects every tool above the threshold regardless of category. A defence-in-depth knob.
BuiltInTools.GetReadOnly() returns every tool with no state mutation. Build research agents that cannot break anything.
A RequireApproval rule pauses execution and emits an approval event. Hook it to a Slack bot or a pull-request style UI.
A safe chat profile only allows pure-computation tools. A dev assistant profile grants more, but with deny rules and approvals on the dangerous bits. Both are five-line policies.
Lock the agent down to pure-computation categories, deny I/O and network, and cap the risk level.
using LMKit.Agents.Tools; var chatPolicy = new ToolPermissionPolicy() .AllowCategory("data", "text", "numeric", "utility", "security") .DenyCategory("io", "net") .SetMaxRiskLevel(ToolRiskLevel.Low); var agent = Agent.CreateBuilder(model) .WithTools(t => { foreach (var tool in BuiltInTools.GetAll()) t.Register(tool); }) .WithPermissionPolicy(chatPolicy) .Build();
Grant broader access with wildcard allows and targeted denies, and require approval for shell execution.
using LMKit.Agents.Tools; var devPolicy = new ToolPermissionPolicy() .AllowCategory("data", "text", "numeric", "utility", "security") .Allow("filesystem_*") // allow all filesystem tools .Deny("filesystem_delete") // but never delete .Allow("http_get", "http_head") // read-only HTTP .Deny("http_post", "http_put", "http_delete") // no mutating HTTP .Allow("websearch") .RequireApproval("process_*"); // shell exec needs human OK
The built-in tool registry exposes filters by risk, category, and read-only status. Use them to compose an allow-list rather than write a deny-list.
using LMKit.Agents.Tools.BuiltIn; var safeOnly = BuiltInTools.GetByMaxRisk(ToolRiskLevel.Low); var ioTools = BuiltInTools.GetByCategory("io"); var readers = BuiltInTools.GetReadOnly(); // Compose an allowlist for a research agent. var research = readers .Where(t => t.Category is "data" or "document" or "text" or "net") .Where(t => t.RiskLevel <= ToolRiskLevel.Medium);
No standardised metadata. Risk and side effects are documented in prose. Permission policies are bring-your-own.
Plugin filters exist but operate on names and method signatures, not on declared side-effect categories.
Every built-in tool ships IToolMetadata. Custom tools declare their own. ToolPermissionPolicy reasons over both. Audit trails come for free.
The full tool catalogue and how to extend it with custom tools.
Wrap tool invocations in middleware for redaction, logging, or salvage.
How-to guide combining policies, approvals, and tracing.
Conceptual reference for the permission model.
Working console demos on GitHub, step-by-step how-to guides on the docs site, and the API reference for the classes used on this page.
ToolPermissionPolicy: allow / deny / require-approval per tool.
Read the guide → How-to guideInspect, rewrite, or block tool calls before they execute.
Read the guide → How-to guideEnd-to-end: policy-driven agent with audit logs.
Read the guide →