# Modes and approvals

> The agent's two access modes, what each one allows, and the operations that always wait for your approval.

Source: https://opendb.tools/en/docs/modes-and-approvals

## Two access modes

The agent works in one of these two modes.

| | Read-only | Read-write |
|---|---|---|
| Explore the schema, read data | Yes | Yes |
| Show tables, key figures, charts, plans | Yes | Yes |
| Read the project's files | Yes | Yes |
| Update the project memory | Yes | Yes |
| Insert, update, delete rows | No | Yes, within your privileges |
| Change the structure | No | Yes, within your privileges |
| Export the database | No | Yes, with the `EXPORT` privilege |
| Send an email | No | Yes, with the `SEND MAIL` privilege |
| Write, copy, delete a file | No | Yes |

The mode changes the **list of tools** given to the model, not just its instructions. In read-only mode, the agent has no tool able to write: it cannot change the database, however hard it is asked.

## Switch modes

- In a conversation: the selector under the input field, or `Ctrl` + `.`.
- By default: **Settings → AI agent → Default access mode**. The default mode after installation is read-only.

If you have no write privilege on the project, a read-write request is brought back to read-only by the server.

## What requires an approval

In read-write mode, some operations stop and wait for your decision.

| Operation | What you see |
|---|---|
| A query containing `DELETE`, `DROP`, `TRUNCATE`, `ALTER` or `UPDATE` | The query, its parameters, the reason for the approval and the number of rows affected |
| Creating a record | A form generated from the table's structure, pre-filled |
| Sending an email | An editable email form |
| Changing the allowed recipients | A confirmation |
| Deleting a file | A confirmation |

A plain `INSERT` runs without approval.

## The number of rows affected

For an `UPDATE` or a `DELETE`, OpenDB runs the query as a **dry run** in a transaction that it rolls back at once, and shows how many rows it would change. You decide knowing the real impact.

On MySQL, this estimate is only made if every table mentioned uses InnoDB. A MyISAM table cannot be put back in its original state after a trial run.

## Approve or reject

- **Approve**: the operation runs, and the agent carries on with the real result.
- **Reject**: nothing runs. You can add a reason, which is passed on to the agent.

The agent is instructed not to rephrase a rejected operation to get it through another way.

## What runs is what you approved

When creating a record or sending an email, you can edit the form before approving. OpenDB then runs **the values you submitted**, never the ones the model had suggested. The agent is then told what was actually done and what you changed.

## What is always refused

Whatever the mode, the agent cannot:

- manage the accounts, roles or privileges of the database server;
- create or drop a database;
- change the server configuration;
- run several statements in a single call;
- query a table that is hidden from it.

## In the terminal

Approvals work the same way in `opendb chat`: they are presented one by one, with the same forms. See [Chat in the terminal](/en/docs/cli).
