bots-garden/mini-mepublic Fork
⑂ v2.2.0
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
guard-tool-calls-with-a-decision-model.md · 68 lines · 4.7 KBmarkdown
Blame HistoryOpen raw

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

  1. Put the questions in the decider's file, under decision.questions.
  2. Put a decisionTool block in the agent's file: decider, matcher, a state that gives the decider what it needs and nothing more, rules.
  3. 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

  1. 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 } }
    
  2. Triage shell commands: allow the safe ones, refuse the worst — measured in demos/decision-commands-new/: questions risk (choice read-only · local-change · dangerous) and destructive (noul); deny when dangerous ≥ 0.8 and destructive yes ≥ 0.7, allow when read-only ≥ 0.8 and destructive no ≥ 0.7.

  3. 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}", questions internal (noul: this machine or a private network) and site (choice documentation · code · other), two deny rules. fetch_content never asks, so only a deny acts.

  4. A scripted agent that reads and changes nothing (mm -p, CI): recipe 1 with yolo: false. In -p nobody can answer a confirmation, so every call the rule does not allow is rejected.

  5. 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
    
  6. 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$, one deny rule.

  7. Guard an MCP server: matcher on 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 choice effect (read · write · destroy); allow read, deny destroy, the rest asks.

  8. A git policy: a choice git (inspect · commit · push · rewrite-history) on ^bash$; allow inspect, deny rewrite-history (push --force, reset --hard on a shared branch), the rest asks.

  9. Stay inside the project (workshops, beginners): state: "In {cwd}: {input.command}", a noul outside ("The command reads or changes files outside the working directory"), one deny rule.

  10. Keep secrets out of commands: a noul secret ("The command prints or sends a password, a key, a token or ~/.ssh"), one deny rule.

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, a preToolCall hook.
  • Quieter: notice: false hides 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 preToolCall hook; the block runs after it.

See also

 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
# 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](triage-commands-with-a-decision-model.md), and every key in the [configuration reference](../reference/configuration.md#decisiontool)) and that you write the decider's questions yourself (see [How to write the questions of a decider](write-decision-questions.md)).

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

1. Put the questions in the decider's file, under `decision.questions`.
2. Put a `decisionTool` block in the agent's file: `decider`, `matcher`, a `state` that gives the decider what it needs and nothing more, `rules`.
3. 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

1. **Let read-only commands run without asking** — measured in `demos/decision-commands-new-simple/` (read 0.92–0.99, change 0.03–0.13):

   ```yaml
   # 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 } }
   ```

2. **Triage shell commands: allow the safe ones, refuse the worst** — measured in `demos/decision-commands-new/`: questions `risk` (choice `read-only` · `local-change` · `dangerous`) and `destructive` (noul); `deny` when dangerous ≥ 0.8 and destructive yes ≥ 0.7, `allow` when read-only ≥ 0.8 and destructive no ≥ 0.7.

3. **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}"`, questions `internal` (noul: this machine or a private network) and `site` (choice `documentation` · `code` · `other`), two `deny` rules. `fetch_content` never asks, so only a deny acts.

4. **A scripted agent that reads and changes nothing** (`mm -p`, CI): recipe 1 with `yolo: false`. In `-p` nobody can answer a confirmation, so every call the rule does not allow is rejected.

5. **Protect sensitive files** from the file tools:

   ```yaml
   # 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
   ```

6. **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$`, one `deny` rule.

7. **Guard an MCP server**: `matcher` on 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 choice `effect` (`read` · `write` · `destroy`); `allow` read, `deny` destroy, the rest asks.

8. **A git policy**: a choice `git` (`inspect` · `commit` · `push` · `rewrite-history`) on `^bash$`; `allow` inspect, `deny` rewrite-history (`push --force`, `reset --hard` on a shared branch), the rest asks.

9. **Stay inside the project** (workshops, beginners): `state: "In {cwd}: {input.command}"`, a noul `outside` ("The command reads or changes files outside the working directory"), one `deny` rule.

10. **Keep secrets out of commands**: a noul `secret` ("The command prints or sends a password, a key, a token or ~/.ssh"), one `deny` rule.

## 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, a `preToolCall` hook.
- **Quieter**: `notice: false` hides 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 `preToolCall` hook; the block runs after it.

## See also

- Every key, notice and error: [Configuration reference](../reference/configuration.md#decisiontool)
- What the decider can and cannot know, and why a deny wins: [Decision models](../explanation/decision-models.md#a-tool-call-decision-judges-the-call-alone)