Module policy
Expand description
Per-tool execution policy — timeout, caching, and confirmation.
A ToolPolicy describes optional runtime enforcement attached to an
individual tool. PolicyTool is a ToolFunction decorator that wraps
an inner tool and enforces its policy on every call:
- timeout: the inner call is raced against [
tokio::time::timeout]; on elapse,ToolError::Timeoutis returned and the inner future dropped. - cache: successful results are memoized in a concurrent map keyed by
(tool name, canonical-JSON args). Repeat calls with identical args return the cached value without re-invoking the inner tool. Errors are not cached. - confirm: a declarative flag recorded on the policy and surfaced via
PolicyTool::requires_confirmation. The flag is never silently dropped; full interactive confirmation wiring is handled by the session runtime.
Structs§
- Policy
Tool - A
ToolFunctiondecorator that enforces aToolPolicy. - Tool
Policy - Optional per-tool execution policy.