Skip to main content
Hooks live on a profile in configuration.hooks, at most 16 of them. Every hook that matches has to pass. List order still matters: it’s the order hooks run outside tool calls, the order of the asks a person sees, and it picks which deny gets reported when more than one hook says no.

Points

After-output hooks cannot undo external effects. Once a tool has run, the hook only controls what gets persisted and returned.

Matching

match has three optional parts, and a hook fires only when every part it sets matches. Omit match entirely to run on every event at that point.
  • tools (tool points only): exact names (payments.transfer) or one trailing wildcard (billing.*). A bare * is rejected; leave tools out to match every tool.
  • levels (tool points only): any of read, write, admin. Built-in tools and the managed providers Matrices runs itself have a fixed level, and a tool its MCP server marks read-only counts as read. Every other tool has no known level and matches every levels filter, so an unlabeled tool can’t slip past one.
  • where: at most eight conditions over the paths in the table above, using the operators from permissions.

Processors

asyncTimeoutMs is capped at 24 hours. A url processor must be HTTPS (plain http only for localhost or a loopback address). An agent processor can’t itself trigger another agent hook, and a profile with one needs a role that grants tool:builtin:agents.ask without conditions, or its turns won’t start. A hook’s description is your words for why it asks; a person sees it on the ask in place of a bare ID. Sizes are in Limits.

The model processor

A model hook asks one model for a score from 0 to 1: its confidence that the call is acceptable. A fixed frame defines the score, and your instructions go inside it as workspace policy. The model sees the agent and its identity, the tool name and input, the user’s latest message, the assistant text that came with the call, and the turn’s recent tool calls. model picks an exact catalog model ID; leave it out for the platform default. The score is judged against confidence:
  • At or above allow, the hook passes.
  • Below deny, the call is denied with the model’s one-sentence reason.
  • In between, a person decides, and the ask carries the score.
Without a band it’s allow 0.9 and deny 0.1. A band needs both bounds, with 0 ≤ deny ≤ allow ≤ 1, so allow equal to deny never asks and deny: 0 never denies. Tool input over 16 KiB is cut before the model sees it, and a cut input never passes on its own: a score that would allow asks instead. A model hook never defers and never rewrites. One decision takes at most two paid samples, recorded like any other model use against the agent’s profile budget and the thread’s maxCost.

Decisions

A HookResult carries a decision, an optional reason, and an optional rewrite (updatedInput, updatedOutput, or updatedText).

Before a tool call: one round

Every matching hook answers in one round, and the call runs only when all of them pass.
  1. url and model hooks answer together; the POSTs go out at once.
  2. If none of them denied, agent hooks answer.
  3. Any deny blocks the call. The first deny in list order is the one reported.
  4. Every hook that asks, meaning each client hook plus any hook that answered ask, goes to a person as one client wait. Its asks[] holds one entry per asking hook (hookId, processor, reason, and description or score when there is one). The wait’s own hookId is the first hook that asked, and it expires at the shortest asyncTimeoutMs among them.
A url or agent hook that goes async parks the call on its own wait next to the person’s. If it then denies, the person’s wait closes unanswered with status withdrawn, and the turn result lists it under withdrawn with the denier named in reason. Once the person allows, a hook’s ask counts as passing. Only the person can rewrite a call’s input. Resolve with allow and updatedInput, and the call’s url, agent, and model hooks answer again on the edited input, while any other open wait for that call is withdrawn. A hook that returns a rewrite before a call counts as failed. Resolve an allow with "grant": {} and later asks for the same tool in that thread skip the person, and so does any other pending ask in the thread the grant covers. grant.actions (up to 16 tool selectors) widens it to other tools; uses and expiresAt bound it. A grant only replaces the person: every other hook still answers on a covered call, and a deny still blocks it.

At the other points: in order

Matching hooks run in list order. allow and defer continue, with rewrites composing in order: updatedOutput at after_tool_result, updatedText at after_model_response. The first deny ends the chain. A url or agent hook that goes async parks the turn; if it passes, the chain picks up after it.

When a processor fails

A processor fails when it errors, times out, or returns an invalid result. onFailure decides what happens next: onFailure covers processors, not people: a wait nobody answers expires and the call fails with wait_expired.

HookInput

Delivered to url and agent processors:

Default hooks

Create a profile without a hooks field and Matrices installs 13 removable approval hooks. All 13 run at before_tool_call with a client processor, wait up to 24 hours, and are fail_closed. Three rules for the default set:
  • Omitting hooks installs the defaults. That holds for POST /v1/profiles and for an inline profile on POST /v1/agents.
  • hooks: [] installs none. That is the explicit opt-out.
  • Any list you send is authoritative, on create or PATCH. The defaults are not merged back in.
Three more approval hooks have the same shape but aren’t installed by default. Add them to hooks yourself: The profile Slack setup creates carries its own seven instead of the 13: approve-gmail-send, approve-toolset-url, approve-publish, approve-skill-workspace-write, approve-calendar-delete, approve-slack-publish, and approve-memory-workspace-write.

The audit trail

Every evaluated hook writes a hook_decision event carrying hookId, index, point, processor, decision, latencyMs, and, when they apply, reason, rewrote, deliveryId, and score (a model hook’s raw score, before its band judged it). An ask a grant covered records defer with a reason naming the grant. Parked work shows up as pendingWaits on the thread, and GET /v1/threads?state=waiting lists every thread holding one. Resolve with POST /v1/threads/{threadId}/waits/{waitId}/resolve; the walkthrough is Approve a tool call.