Skip to main content
Enforce read-only access with database roles and grants. Use a separate connection with schema-scoped permissions for approved write operations. These controls remain in effect when model output is unexpected.
Create the readonly role without write grants before using this connection. The default_transaction_read_only=on setting blocks ordinary write statements. This setting is a configurable session default. Database ownership and grants remain the security boundary.

Split the roles

Most data-agent questions are read-only. Separate approved writes, such as building a summary table or recording a correction, into agents with dedicated connections. The Engineer’s writes are scoped to a schema (for example dash) that the Analyst never touches. The database rejects DROP TABLE public.users because the Engineer’s role has no write grant on public.

Gate the writes that remain

For writes you do allow, add a human in the loop. requires_confirmation produces a paused run that the client must continue with an approval before the function executes.
For a dedicated writer built on SQLTools, set requires_confirmation_tools=["run_sql_query"]. This pauses every call to the tool, including reads. A narrow custom write tool gives finer control. Gate irreversible actions and leave reads ungated so approval fatigue does not set in.

Layers of defense

Next steps

Developer Resources