How to guard tool calls with a decision model
This guide gives decisionTool recipes: a decision model reads each tool call the block's matcher accepts, and the block's rules let it run without asking (allow), refuse it (deny), or leave it to its usual confirmation. It assumes you know the block (see How to triage commands with a decision model, and every key in the configuration reference) and that you write the decider's questions yourself (see How to write the questions of a decider).
Recipes 1 to 3 were measured on LiquidAI d1-3B (2026-11-28) in the demos named; the others are starting points — measure them on your own calls before you trust a threshold.
Steps common to every recipe
- Put the questions in the decider's file, under
decision.questions. - Put a
decisionToolblock in the agent's file:decider,matcher, astatethat gives the decider what it needs and nothing more,rules. - Start with
display: true: before each judged call you see the state sent and the decider's whole answer. Set the thresholds from those numbers, then turn it off.
Recipes
-
Let read-only commands run without asking — measured in
demos/decision-commands-new-simple/(read 0.92–0.99, change 0.03–0.13):# decider reads_only: { type: noul, instructions: "The command only reads or prints information; it changes nothing." } # agent (yolo: false) decisionTool: matcher: ^bash$ rules: - action: allow when: { reads_only: { is: "yes", min: 0.9 } } -
Triage shell commands: allow the safe ones, refuse the worst — measured in
demos/decision-commands-new/: questionsrisk(choiceread-only·local-change·dangerous) anddestructive(noul);denywhen dangerous ≥ 0.8 and destructive yes ≥ 0.7,allowwhen read-only ≥ 0.8 and destructive no ≥ 0.7. -
Limit the sites the agent reads — measured in
demos/decision-commands-new-websites/:matcher: ^fetch_content$,state: "URL the agent wants to read: {input.url}", questionsinternal(noul: this machine or a private network) andsite(choicedocumentation·code·other), twodenyrules.fetch_contentnever asks, so only a deny acts. -
A scripted agent that reads and changes nothing (
mm -p, CI): recipe 1 withyolo: false. In-pnobody can answer a confirmation, so every call the rule does not allow is rejected. -
Protect sensitive files from the file tools:
# decider sensitive: { type: noul, instructions: "The path is a secret, a key, an environment file or a CI configuration." } # agent decisionTool: matcher: ^(write_file|edit_file)$ state: "File the agent wants to change: {input.path}" rules: - action: deny when: { sensitive: { is: "yes", min: 0.7 } } reason: this file is protected; ask the user to change it -
Stop commands that send project data out: a noul
sends_data("The command sends files or data of the project over the network") on^bash$, onedenyrule. -
Guard an MCP server:
matcheron the server's tool names (^github_), the default state (Tool call in {cwd}: {tool} {input}: the decider sees the tool's name and its arguments as JSON), a choiceeffect(read·write·destroy);allowread,denydestroy, the rest asks. -
A git policy: a choice
git(inspect·commit·push·rewrite-history) on^bash$;allowinspect,denyrewrite-history (push --force,reset --hardon a shared branch), the rest asks. -
Stay inside the project (workshops, beginners):
state: "In {cwd}: {input.command}", a nouloutside("The command reads or changes files outside the working directory"), onedenyrule. -
Keep secrets out of commands: a noul
secret("The command prints or sends a password, a key, a token or ~/.ssh"), onedenyrule.
Variants
- Several tools, different questions: one block has one decider and one
matcher. Group the tools that share questions (^(write_file|edit_file)$); for the rest, apreToolCallhook. - Quieter:
notice: falsehides the🚦lines; a decider that fails is still reported. - A verdict that needs more than thresholds — a list of allowed domains, a check on the file's content, asking another service: write a
preToolCallhook; the block runs after it.
See also
- Every key, notice and error: Configuration reference
- What the decider can and cannot know, and why a deny wins: Decision models
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|