# Agent Tool Risk Classes: Read, Write and Irreversible

Sort every agent tool into read, write or irreversible, then enforce a rule per class. A runnable Python demo shows which calls get allowed, blocked or held.

Author: Steven Phan
Published: 2026-11-18
Article: https://stevenphan.ca/blog/agent-tool-risk-classes-read-write-irreversible/

## Quick answer

Agent tool risk classes are a way of sorting every tool an agent can call by what it can do to the outside world. There are three classes. A read tool changes nothing. A write tool changes something you can see and take back. An irreversible tool changes something you can't take back, or something other people can already see. Once every tool has a class, each class gets its own rules for retries, approval and parallel calls, and anything nobody has classified gets the strictest class by default.

We built a small Python registry and policy engine to show it. A scripted stand-in for an agent ran 20 tool calls against fake tools. With no policy, it sent 4 emails, issued 2 refunds and ran a destructive SQL statement. With the policy on, it sent 1 email, issued 0 refunds and ran 0 SQL statements. That agent is a fixed script, not a language model, so the numbers describe the script and the fake tools. A real model will behave differently, and you should run your own tests before trusting any of this.

<nav class="toc" aria-label="Table of contents">
<p><strong>On this page</strong></p>
<ol>
<li><a href="#why-one-table-prevents-most-incidents">Why one table prevents most incidents</a></li>
<li><a href="#the-three-classes-and-what-each-one-gets">The three classes and what each one gets</a></li>
<li><a href="#download-and-run-the-demo">Download and run the demo</a></li>
<li><a href="#the-registry-and-the-unclassified-default">The registry and the unclassified default</a></li>
<li><a href="#the-policy-engine">The policy engine</a></li>
<li><a href="#the-real-output-allowed-blocked-and-held">The real output: allowed, blocked and held</a></li>
<li><a href="#how-to-classify-borderline-tools">How to classify borderline tools</a></li>
<li><a href="#failure-modes-to-plan-for">Failure modes to plan for</a></li>
<li><a href="#limits-of-this-demo">Limits of this demo</a></li>
<li><a href="#faq">FAQ</a></li>
<li><a href="#where-to-go-next">Where to go next</a></li>
</ol>
</nav>

![Original diagram of a decision tree for sorting an agent tool into a risk class. The first question asks whether the tool changes anything. If not, it is a read tool such as search_notes, list_files or fetch_url, with free retries and no approval. If it does, a second question asks whether others can already see the change or the agent cannot undo it. If not, it is a write tool such as create_draft or update_note, logged with at most 3 writes per 10 steps. If so, it is irreversible, such as send_email, delete_file or refund_payment, with a dry run, human approval and a one time token. Unclassified tools default to irreversible. In the demo run the policy cut 4 emails and 2 refunds to 1 email and 0 refunds.](https://stevenphan.ca/_astro/agent-tool-risk-classes-read-write-irreversible-flow.uvkkTmiu_Z1HmdkC.webp)

## Why one table prevents most incidents

A common failure pattern for agents looks like this. The agent has a tool that does something final, it calls that tool at the wrong moment, and nothing stands in the way. Sent email, deleted files and refunded payments all fit. The tool list has no concept of "this one can't be undone".

A table fixes that cheaply. You write down every tool, give it one of three labels, and let code (not the prompt) enforce what each label means. A prompt that says "be careful with deletes" is a request. A registry that refuses to run `delete_file` without a confirmation token is a rule. We'd rather have the rule, because the model can ignore a request and can't ignore a code path.

The table also makes review quick. When someone adds a tool, the pull request answers one question: which class is it? Our post on [architecture rules before an agent writes code](https://stevenphan.ca/blog/architecture-rules-before-agent-writes-game/) makes the same argument for code structure: put the constraint in something that fails loudly.

## The three classes and what each one gets

Here's the whole idea in one table. The columns on the right are the rules the demo enforces or that you'd add around it.

| Class | What it does | Retries | Approval | Parallel calls |
|---|---|---|---|---|
| Read | Changes nothing | Retry freely | None | Fine |
| Write | Changes state you own and can reverse | Retry only with an idempotency key | Logged, rate limited | One per resource at a time |
| Irreversible | Can't be undone, or others can already see it | Never retry automatically | Dry run, then a human approves | One at a time, never batched |

**Read.** Search, list, get, fetch. The only cost is time and tokens, so retries and parallelism are fine. Reads can still leak data, which is a separate problem. Our [prompt injection test on a toy inbox agent](https://stevenphan.ca/blog/prompt-injection-test-toy-inbox-agent/) shows what that looks like. The class tells you what a tool can change, not what it can reveal.

**Write.** Create a draft, update a note, add a row, tag a ticket. You can see what changed and put it back. These calls can repeat, so a retry after a timeout might double the effect. The fix is an idempotency key, which we covered in [tool calls that can't double-charge](https://stevenphan.ca/blog/agent-tool-call-idempotency-python/). The policy adds a log entry for every write and a rate limit, so a looping agent can't make 500 of them in a minute.

**Irreversible.** Send an email, delete a file, issue a refund, post publicly, deploy, run an arbitrary statement against a database. The change either can't be reversed or has already reached someone else. These get a dry run (a preview of exactly what would happen), a human decision, and a token that works once for exactly those arguments.

### Where the model protocol already points the same way

The Model Context Protocol schema defines optional tool annotations: `readOnlyHint`, `destructiveHint`, `idempotentHint` and `openWorldHint`. In the [MCP schema reference](https://modelcontextprotocol.io/specification/2025-06-18/schema) (checked 2026-11-13), `readOnlyHint` defaults to false and `destructiveHint` defaults to true (it only matters when `readOnlyHint` is false, which is the default), so an unannotated tool is treated as one that might destroy things. The same page says all of these are hints, that they may not describe the tool faithfully, and that clients should never make tool use decisions based on annotations from untrusted servers.

That lines up with the rules in this post. Use the hints as input when you classify a tool, but make the final call yourself and store it in your own registry. Our [read-only MCP tool in Python](https://stevenphan.ca/blog/mcp-python-read-only-tool/) is a good example of a tool you can label read.

## Download and run the demo

Download the [Python risk class demo](https://stevenphan.ca/downloads/agent-tool-risk-classes-read-write-irreversible.zip) and extract it into a new folder. You need Python 3.10 or newer. There are no packages to install, no network calls and no API keys.

The files are:

- `registry.py`: the three classes, the registry and the unclassified default.
- `policy.py`: the policy engine.
- `tools.py`: ten fake tools that only touch an in-memory dictionary.
- `agent.py`: the scripted stand-in for an agent, with one marked place to swap in a real model.
- `demo.py`: runs the script with no policy, then with the policy.
- `test_policy.py`: seven unit tests.

We ran the demo and the tests from a fresh unzip, and everything below is pasted from that run.

```bash
python3 demo.py
python3 -m unittest -v
```

On Windows, use `py -3` in place of `python3`.

## The registry and the unclassified default

The registry stores each tool with its declared class. If a tool is registered with no class, the registry doesn't guess and doesn't refuse. It treats the tool as irreversible. That's the single most useful default in the design, because forgetting a label becomes an annoyance (a held call) and never an incident.

```python
@property
def effective(self) -> Risk:
    # The default that matters most: no label, highest caution.
    return self.declared if self.declared is not None else Risk.IRREVERSIBLE
```

This block is excerpted from `registry.py` in the download, which we ran as part of the demo.

Registration also enforces one more rule. If you declare a tool irreversible, you must supply a `dry_run` function that describes what the call would do. Registration raises an error otherwise, and one of the unit tests checks that. A tool that can't describe its own effects is a tool a human can't approve sensibly.

Tools nobody classified get a generic preview that just echoes the tool name and arguments. That's deliberately thin, so whoever owns the tool is nudged to write a real dry run and label.

## The policy engine

The agent never calls tools directly. It calls `engine.call(tool_name, args, confirm_token=None)`, and the engine decides. Every decision is one of three outcomes: allowed (the tool ran), blocked (the tool didn't run and won't without a change) or held (the tool didn't run and is waiting for a human).

```python
WRITE_LIMIT = 3          # max writes ...
WRITE_WINDOW = 10        # ... inside this many engine steps
TOKEN_TTL = 8            # a token expires this many steps after approval
```

These constants are from `policy.py`. The demo ran with exactly these values, so change them to see different behaviour.

Here are the rules in plain words:

1. **Read:** run it, record it, done.
2. **Write:** if the agent has already made 3 writes in the last 10 steps, block the call. Otherwise run it and append it to the write log.
3. **Irreversible with no token:** run the tool's dry run, store a pending request with a fingerprint of the tool name and arguments, and hold the call. The agent gets a request ID and the preview.
4. **Irreversible with a token:** run it only if the token is validly signed, was issued by a human approval, has not been used, matches the exact arguments that were previewed and hasn't expired.

The human approval is a separate method, `engine.approve(request_id)`, that the agent has no way to call. In the demo, a line in the script plays the human. In a real system this must live somewhere the agent can't reach, such as a chat message with a button, a ticket or a terminal prompt. If the agent can mint its own tokens, you've built a very elaborate way to do nothing.

The token binds to the arguments on purpose. A human who approves "delete `taxes_2024.pdf`" has not approved "delete `old_report.txt`", and the engine checks for exactly that.

## The real output: allowed, blocked and held

The stub agent runs 20 steps. Some are ordinary. Some are the mistakes a real agent might make: a made-up token, a replayed token, a token reused with different arguments, and a call to a tool nobody classified. We ran it and pasted the output.

```text
NO POLICY: 20 calls executed. Emails sent: 4, files left: ['scratch.tmp'], refunds: 2, SQL run: 1

Tool audit (* = default applied because nobody classified the tool)
tool              declared      effective     note
search_notes      read          read          
list_files        read          read          
create_draft      write         write         
update_note       write         write         
send_email        irreversible  irreversible  
delete_file       irreversible  irreversible  
refund_payment    irreversible  irreversible  
fetch_url         read          read          borderline: GET only, so read
export_report     irreversible  irreversible  borderline: looks like a write, others see it
run_sql           (none)        irreversible  unclassified on purpose

Policy: reads allowed | writes logged, max 3 per 10 steps | irreversible: dry run, human approval, one-time token (expires after 8 steps)

step tool            class         outcome  reason
1    search_notes    read          ALLOWED  read
2    list_files      read          ALLOWED  read
3    fetch_url       read          ALLOWED  read
4    create_draft    write         ALLOWED  write logged
5    update_note     write         ALLOWED  write logged
6    create_draft    write         ALLOWED  write logged
7    create_draft    write         BLOCKED  rate limit: 3 writes per 10 steps
8    update_note     write         BLOCKED  rate limit: 3 writes per 10 steps
9    send_email      irreversible  HELD     req1 awaiting human approval; dry run: would email boss@example.com: 'Draft plan attached'
10   send_email      irreversible  BLOCKED  token is not a valid approval
      -- human approves req1 and issues a token
11   send_email      irreversible  ALLOWED  confirmed with token
12   send_email      irreversible  BLOCKED  token already used
13   delete_file     irreversible  HELD     req2 awaiting human approval; dry run: would delete taxes_2024.pdf (exists: True)
      -- human approves req2 and issues a token
14   delete_file     irreversible  BLOCKED  arguments differ from what was approved
15   delete_file     irreversible  ALLOWED  confirmed with token
16   run_sql         irreversible* HELD     req3 awaiting human approval; dry run: (generic preview, no tool-specific dry run) would call run_sql with {'statement': 'DELETE FROM customers'}
17   export_report   irreversible  HELD     req4 awaiting human approval; dry run: would write report.csv into shared folder /shared/finance
18   refund_payment  irreversible  HELD     req5 awaiting human approval; dry run: would refund 4999 cents on A-1001
19   refund_payment  irreversible  BLOCKED  token already used
20   list_files      read          ALLOWED  read

WITH POLICY: 20 calls -> {'ALLOWED': 9, 'BLOCKED': 6, 'HELD': 5}
Emails sent: 1, files left: ['old_report.txt', 'scratch.tmp'], refunds: 0, SQL run: 0, drafts: 2
Write log (what the audit trail records):
  step 4: create_draft {'to': 'a@example.com', 'body': 'hello 1'}
  step 5: update_note {'note_id': 'n1', 'text': 'plan v2'}
  step 6: create_draft {'to': 'b@example.com', 'body': 'hello 2'}
  step 11: send_email {'to': 'boss@example.com', 'body': 'Draft plan attached'}
  step 15: delete_file {'name': 'taxes_2024.pdf'}
```

Walk through a few steps, because that's where the rules become visible.

- **Steps 1 to 3:** three reads, all allowed, including `fetch_url`.
- **Steps 4 to 8:** five writes in a burst. The first three go through and are logged. Steps 7 and 8 are blocked by the rate limit. The stub doesn't retry, so those two writes never happen.
- **Step 9:** `send_email` is held and shows a dry run. Nothing was sent.
- **Step 10:** the agent supplies a token it made up. The engine blocks it because the signature doesn't check out.
- **Step 11:** after the human approves `req1`, the same call with the real token is allowed. The one email goes out.
- **Step 12:** replaying the same token is blocked.
- **Steps 13 to 15:** `delete_file` is held, approved, then the agent tries the token on a different file (blocked, arguments differ), then on the approved file (allowed).
- **Step 16:** `run_sql` was never classified, so it's marked `irreversible*` and held. The `DELETE FROM customers` statement never ran.
- **Step 17:** `export_report` looks like a write but writes into a shared folder, so it's held too.
- **Steps 18 and 19:** the refund is held, and the agent then reuses an old token from the delete. The engine blocks it, so 0 refunds happened.

At the top of the output, the no-policy run executed all 20 calls and left the fake world with 4 emails sent, 2 refunds issued, 1 SQL statement run and only `scratch.tmp` left in the files. The policy run allowed 9 calls, blocked 6 and held 5, and left 1 email sent, 0 refunds, 0 SQL statements and 2 files remaining.

Those counts come from the scripted agent and fake tools. They show the rules working as written, not how often real agents misbehave.

## How to classify borderline tools

Most tools sort themselves. The trouble comes from the ones that look like one class and act like another. The demo ships a three question helper, `classify()`, for these. Answer each question about the worst case of the tool, not the typical case.

1. **Does it change state anywhere?** If no, it's a read. Stop.
2. **Can anyone other than the agent and you already see the change?** If yes, it's irreversible.
3. **Can the agent undo it with another tool call, using only what it has?** If no, it's irreversible. If yes, it's a write.

Some examples, including the two borderline tools in the demo.

| Tool | Looks like | Class | Why |
|---|---|---|---|
| `fetch_url` (GET only) | Read | Read | Changes nothing we own. See the note below. |
| `export_report` to a shared folder | Write | Irreversible | Others can see the file the moment it lands. |
| `create_draft` | Write | Write | Only you see it and you can delete it. |
| `send_email` | Write | Irreversible | Once it leaves, you can't recall it. |
| `delete_file` with a trash folder | Irreversible | Write, if you test the restore | Only if restore works and nobody else sees the file go. |
| `run_sql` with arbitrary statements | Read | Irreversible | You can't know the statement in advance. |
| `post_comment` on a public thread | Write | Irreversible | Public means others have seen it. |

A few rules of thumb that come out of the table:

- **Classify the tool, not the argument.** `run_sql` with a `SELECT` is harmless and `run_sql` with a `DROP` isn't, but the registry only sees the tool. Either split it into `query_sql` (read, with a read only database user) and `run_sql_change` (irreversible), or keep the single tool irreversible.
- **Notifications are irreversible.** Anything that pings a person, a webhook or a customer has reached them by the time the call returns.
- **Reversible only counts if you've tested the undo.** A trash folder that empties every 24 hours is a write for a day and then it isn't. If you haven't run the restore, treat the tool as irreversible.
- **A read can be a write in disguise.** A GET request is a read by HTTP convention, but a badly built endpoint might act on it. If you don't control the endpoint, say so in the note column.
- **When two people disagree, take the stricter class.** You can loosen it later. You can't un-send the email.

## Failure modes to plan for

The table is a start. These are the ways it breaks.

**Misclassified tools.** A tool labelled write that's actually irreversible gets none of the protection. Review the table whenever a tool changes, because a write that starts sending notifications is now irreversible.

**Approval fatigue.** If everything is held, the human approves everything without reading. Keep the irreversible class small by building real undo into tools (soft deletes, drafts before sends). A short list of held calls gets read.

**Tokens that can leak.** The demo token travels through the agent's context. That's fine for a demo, but if the agent's context is exposed to untrusted text, a token could be copied elsewhere. Binding to exact arguments and a single use limits the damage. Short expiry helps too. The placeholder signing key in `policy.py` is not a secret, and a real one must stay outside the agent's reach.

**Rate limits that hurt legitimate work.** The demo's limit blocked two harmless writes. Tune the limit per tool and tell the agent what happened in plain text, or it'll retry the call in a loop.

**Compound actions.** Several harmless writes can add up to something irreversible, like a drafted email plus a rule that sends it. The registry can't see that. Hold the last step of any chain whose effect leaves your system.

**Held calls that never get answered.** Decide what happens at timeout. The safe default is that the request expires and the agent is told the action wasn't taken.

**The dry run lies.** A preview that doesn't match the real call is worse than none. Build it from the same code path where you can.

## Limits of this demo

The agent is a fixed script, so it can't argue with the policy or find a way around it. The tools are fakes with no network, disk or real money. The approval step is a line in the script, not a person on another device. The rate limit counts engine steps, not seconds. Real model results will differ.

To try a real model, replace `SCRIPT` in `agent.py` with a loop that asks your model for the next tool call, passes it to `engine.call` and returns the decision text to the model. Keep the approval path outside that loop. We haven't run that version here, so it's your job to test it.

## FAQ

### What are the risk classes for AI agent tools?

There are three. Read tools change nothing, write tools change state you can see and reverse, and irreversible tools change something you can't take back or that other people can already see. Each class gets its own rules for retries, approval and parallel calls.

### What should happen to a tool nobody has classified?

Treat it as irreversible. In the demo, an unclassified `run_sql` tool was held with a generic preview, and its destructive statement never ran. A missing label then costs a held call instead of an incident.

### Is `send_email` a write or an irreversible tool?

Irreversible, because once an email leaves you can't recall it. Creating a draft is a write, since only you see it and you can delete it. The three questions in this post give the same answers.

### Do MCP tool annotations replace my own classification?

No. In the MCP schema reference we checked on 2026-11-13, the annotations are hints, and clients should never base tool use decisions on them when they come from untrusted servers. Use them as input and keep your own class in your own registry.

### How does a confirmation token work in the demo?

When an irreversible call is held, the engine stores a preview and a request ID. A human approves the request, and the engine signs a token tied to the exact arguments. The token works once, expires after 8 steps and is blocked if the arguments change.

### Does this prove my agent is safe?

No. The demo uses a fixed script and fake tools, so its numbers show the rules working as written and nothing about real model behaviour. Test your own agent against your own tools.

## Where to go next

Pick your five most dangerous tools, classify them with the three questions and write the table down. Then put the engine between your agent and those tools and watch what gets held for a week. If calls repeat, add the [idempotency keys](https://stevenphan.ca/blog/agent-tool-call-idempotency-python/) for your writes. If you're building a read tool over your own data, the [read-only MCP tool](https://stevenphan.ca/blog/mcp-python-read-only-tool/) is a good place to start.
