How to Configure AutoGen SQL Server Approval
To set up autogen sql server approval, pair human review steps with strict database roles. Your agent builds the SQL query, and a reviewer checks it before it runs. Most teams start by giving the agent a shared login and broad database rights. When roles are too wide, one bad prompt can delete tables or leak data. This guide explains how native SQL Server roles and agent review loops work together. How native autogen sql server approval works A safe setup starts inside SQL Server by picking t
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
To set up autogen sql server approval, pair human review steps with strict database roles. Your agent builds the SQL query, and a reviewer checks it before it runs. Most teams start by giving the agent a shared login and broad database rights. When roles are too wide, one bad prompt can delete tables or leak data. This guide explains how native SQL Server roles and agent review loops work together.
How native autogen sql server approval works
A safe setup starts inside SQL Server by picking the right user type. A database user is the identity of a login when it enters a database. SQL Server offers thirteen types of database users for different access needs. If an agent needs many databases on one instance, use a login in master. If it needs just one or a few databases, use a contained database user. This user has its own password and does not tie to a master login. An admin must first turn on contained databases on the server and database.
Next, you assign the agent user to a fixed database role. All roles, including the public role, have basic rights to connect. You cannot change the rights built into fixed database roles. Adding a user to the data reader role lets it read all user tables. It can also read all views across that database. If the agent must change records, the data writer role allows adds and updates. That role also lets the user delete data in all user tables. Never place an agent in the owner role. The owner role can run all maintenance tasks and even drop the database.
On the client side, the agent framework adds a human check before execution. The model drafts a query based on the task and pauses the run. A human reviewer reads the text and types a reply to allow or block it. Only after the reviewer approves the text does the tool send it to SQL Server.
What native setup solves and what it misses
Native roles and client checks solve the basic problem of who can log in. Fixed deny roles can even block reads or writes across all user tables. For example, the deny data writer role stops any adds, changes, or deletes. Client review loops also help catch clear mistakes before the agent sends a command.
Still, this native setup leaves a major gap during live operations. Database roles apply to the whole user session, not to single SQL statements. If an agent needs write rights for one task, it keeps them for all tasks. The database cannot pause a risky delete command to ask a human for help. Also, client review steps live inside the app code that runs the agent. If a builder turns off the check in code, the database never knows. Even with the data reader role, an agent can read every table at once. Native roles cannot rewrite sensitive fields like emails, phone numbers, or card numbers in results.
Approval Chains & Escalation + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why runtime query checks matter for AI agents
Relying on app code for human review puts too much trust in the client. Builders often skip manual prompts in test runs and forget to turn them back on. When the agent connects straight to the database, it holds the raw password. Any script running in that same space can use those credentials without a check.
Teams need a way to enforce rules outside the agent code itself. Each query should face a check based on what the statement actually does. Read queries on safe tables can run right away while writes wait for review. Masking rules can also rewrite national IDs or card numbers in the query output. This keeps the workflow fast while stopping bad queries before they hit the data.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server. It reads plain batches and parameterized queries on the TDS wire while passing Windows login through untouched.
Before a batch hits the server, hoop.dev guardrails check the statement against your rules. Disallowed actions get a native TDS error with your message. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns that match your rules. Every query and decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Which SQL Server role is safest for an AI agent?
Start with the fixed data reader role so the agent can only read tables. Pair it with the deny data writer role to block all data changes.
Should an AI agent use a master login or a contained user?
Use a contained database user if the agent only needs one database. This keeps the user isolated from the master database and other server instances.
Why is client-side agent approval not enough on its own?
Client checks happen in the app code, which a developer can change or bypass. The database itself still runs any command that the logged-in role allows.
Related guides
In this post