Agent hooks
Agent hooks are Provon's tool-execution boundary for local coding agents. provon setup guard writes a synchronous PreToolUse hook that asks Provon for an allow/deny decision before a tool runs; provon setup ingest writes asynchronous trace hooks that upload the session as evidence. The two components are independent; select both in provon setup or run both subcommands.
Unlike OpenTelemetry or transcript backfill, hooks can stop an action in real time.
What gets installed#
| Tool | Guard event (synchronous) | Trace events |
|---|---|---|
| Claude | PreToolUse |
PostToolUse, Stop |
| Codex | PreToolUse |
PostToolUse, Stop |
| Cursor | preToolUse |
stop, sessionEnd |
| OpenCode | tool.execute.before |
session.idle plugin |
| dsh | tools/pre-execute |
agent/turn-stopping plugin |
| Pi | tool_call |
agent_settled extension |
Guard hooks run synchronously and must answer within the tool's hook timeout. Trace hooks hand the
payload to a detached reporter and return immediately. Plugin-based targets (OpenCode, dsh, Pi) run
the same provon guard evaluate entry from their native hook and translate a deny into the host's
block contract; dsh's persisted session log is not read by this build's trace handler, so dsh is
guard-only for live capture.
Prerequisites#
- A Provon project and a project API key with:
guardrails:evaluatefor the PreToolUse decision;telemetry:ingestfor decision and session evidence.
- A default project API key already includes both capabilities. Re-create older keys that predate
guardrails:evaluate. - The
provonbinary must be resolvable from the agent's non-interactive shell. The installer prepends the Node directory that contains it. - The agent must trust the generated hook command. Codex records trust state automatically; Cursor and Claude may prompt on first use.
Authenticate before installing. Both commands read the active profile or the global
--project/--api-key flags; they do not read PROVON_API_KEY from the environment.
provon auth loginInstall#
# Install guard and trace hooks separately (or select both in `provon setup`)
provon setup guard
provon setup ingest
# Limit to agents, using the same --agent ids as setup gateway
provon setup guard --agent claude-code --agent codex
provon setup ingest --agent opencode,pi
# Repository-scoped instead of global
provon setup guard --project-dir .
provon setup ingest --project-dir .Re-running is idempotent: Provon-owned entries of that component are replaced, the other component and other tools' hooks are left untouched.
Fail mode#
If the decision API cannot be reached, the hook follows the baked fail mode:
provon setup guard --fail-mode closedopen(default) allows the tool call and records a failed decision.closeddenies the tool call with a "Provon guard could not be reached" reason.
A missing API key or a 401/403 from the decision API always denies, regardless of the fail mode:
those are configuration errors, not transient outages. Use closed when availability of the agent is
less important than preventing unguarded execution during an outage.
Decision semantics#
The hook calls POST /v1/guardrails/evaluate with a pre_tool_use stage and a Gateway-shaped
body whose last tool call is the pending call. Provon loads the project's guardrail policy and
evaluates the configured tool-call rules against that call.
| Policy state | Hook result |
|---|---|
Guardrails off |
Allow; no decision span. |
audit with a match |
Allow; record an audit decision and a trace span with wouldBlock. |
enforce with a block |
Deny; return the rule and a bounded reason to the agent. |
enforce with a transform |
Deny; this boundary cannot rewrite tool arguments, so the call is stopped instead of un-redacted. |
The following rules are evaluated before execution: tool-call denylist, PII, secret leak, word list, and semantic policy. Rules that require request bodies or complete output (for example structured output contracts) remain Gateway-only.
Evidence#
Each decision is uploaded as a provon.guard.tool_call span with:
- tool name, source, session id, and cwd;
- decision (
allow/deny), mode, matched flag, and would-block flag; - rule id, action, and a bounded reason.
The existing transcript hooks upload the surrounding run. In the Workbench, filter Traces by the
provon.guard.tool_call operation to review decisions.
Verify#
- Install hooks for one tool:
provon setup guard --agent claude-codeandprovon setup ingest --agent claude-code. - Run a session and ask the agent to call a tool that matches an enforced rule.
- Confirm the tool call is denied in the agent, and a decision span appears in Traces.
- Switch the rule to Audit and repeat; the call should proceed with a
wouldBlockspan.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
| Hook installs but never denies | Guardrails are off, no rule matches, or the key lacks guardrails:evaluate |
Check Guardrails mode and rule; create a key with the default capabilities; re-install |
| Hook denies everything | Enforce mode with a broad rule, or fail mode closed during an outage |
Review the rule; switch to Audit; confirm the API origin is reachable from the agent shell |
| Decision spans are missing | PostToolUse/Stop trace hooks not installed, or telemetry:ingest missing |
Re-run the install; check the project key; see Ingest sync for upload diagnostics |
| Agent reports an untrusted hook | The agent requires explicit trust for new commands | Approve the Provon hook in the agent's hook/trust settings; Codex trust is written automatically |
| Tool arguments contain secrets in logs | The agent or reporter logged the raw payload | Decision spans store rule ids and bounded reasons, not tool arguments; check the agent's own logging settings |
Uninstall#
provon setup guard --uninstall
provon setup ingest --uninstallEach command removes only its own component's Provon-owned hooks from the selected tools.