pub struct ToolPolicy { /* private fields */ }Expand description
Tool permission policy: permission tiering + sandbox gate.
When no policy is configured the executor does not enforce anything; once configured,
every tool execution is checked via ToolPolicy::check before it runs.
§Example
use lc_agents::{AgentExecutor, ToolPolicy, ToolRisk};
let policy = ToolPolicy::new()
.risk("code_interpreter", ToolRisk::Dangerous)
.sandboxed("code_interpreter"); // wrapped in a restricted env, allowed to run
let executor = AgentExecutor::new(agent, tools).with_tool_policy(policy);Implementations§
Source§impl ToolPolicy
impl ToolPolicy
Sourcepub fn new() -> Self
pub fn new() -> Self
Empty policy: every tool defaults to ToolRisk::Safe, the permitted tier is the
highest, and there is no sandbox allowlist.
Sourcepub fn risk(self, name: impl Into<String>, risk: ToolRisk) -> Self
pub fn risk(self, name: impl Into<String>, risk: ToolRisk) -> Self
Declare a tool’s risk level.
Sourcepub fn sandboxed(self, name: impl Into<String>) -> Self
pub fn sandboxed(self, name: impl Into<String>) -> Self
Declare that a tool is wrapped in a restricted environment (sandbox-gate allowlist).
Sourcepub fn with_default_risk(self, risk: ToolRisk) -> Self
pub fn with_default_risk(self, risk: ToolRisk) -> Self
Set the default risk level for tools not explicitly declared.
Sourcepub fn with_max_permitted(self, risk: ToolRisk) -> Self
pub fn with_max_permitted(self, risk: ToolRisk) -> Self
Set the highest risk tier the executor permits (permission tiering).
Sourcepub fn allow_unrestricted_dangerous(self, allow: bool) -> Self
pub fn allow_unrestricted_dangerous(self, allow: bool) -> Self
Explicitly allow unsandboxed dangerous tools (an escape hatch for tools that are dangerous but must run bare; off by default).
Sourcepub fn check(&self, name: &str) -> Result<(), AgentError>
pub fn check(&self, name: &str) -> Result<(), AgentError>
Pre-execution gate: returns AgentError when the tool does not meet the policy,
Ok(()) when it passes.
Trait Implementations§
Source§impl Clone for ToolPolicy
impl Clone for ToolPolicy
Source§fn clone(&self) -> ToolPolicy
fn clone(&self) -> ToolPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more