Module policy

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::Timeout is 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§

PolicyTool
A ToolFunction decorator that enforces a ToolPolicy.
ToolPolicy
Optional per-tool execution policy.