ToolCall. Audit behaviour
(ToolCall v0.4.0)
Copy Markdown
Dispatch audit hooks.
A policy is a module implementing record/1. Configure it with
use ToolCall, audit: Policy or run/4 audit: Policy; audit: nil disables
a module policy for one call. record/1 receives a
%ToolCall.Audit.Entry{} once per dispatch attempt, including resolve
failures, approvals, timeouts, raises and resolve/execute policy exceptions.
This is a hook, not a log store: the application persists the entry, applies
redaction and retention, and decides whether a failed audit is fatal. The
library calls the hook synchronously and ignores an exception it raises, so
a broken audit does not change the tool result. A policy module without
record/1 is a configuration error and raises ArgumentError before the
hook runs. The raw args and context are passed through; redact them in
record/1 when they contain secrets.
Summary
Types
Callbacks
@callback record(ToolCall.Audit.Entry.t()) :: term()
Functions
Builds the entry passed to record/1.
outcome is one of the outcome/0 values; opts accepts
:duration_us, :error, :approval_request_id and :timeout.
Custom dispatchers call this when they bypass ToolCall.run/4.