How to Configure OpenAI Agents SDK SQL Server Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openai agents sdk sql server approval by pausing tool calls for review. You also pair that review step with a restricted database user. Most teams start by giving an agent a standard database login and password. When that role has broad permissions, a bad prompt can alter or erase live tables. Putting human checks and strict role limits in place prevents accidental data loss. How openai agents sdk sql server approval works with database roles An agent runs queries by calling a Pyth

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.

You set up openai agents sdk sql server approval by pausing tool calls for review. You also pair that review step with a restricted database user. Most teams start by giving an agent a standard database login and password. When that role has broad permissions, a bad prompt can alter or erase live tables. Putting human checks and strict role limits in place prevents accidental data loss.

How openai agents sdk sql server approval works with database roles

An agent runs queries by calling a Python tool function that you define. The model reads the user request and picks the right tool to run. It then builds a SQL string and passes that string to the tool. Without an approval check, the tool sends that query straight to the database.

To add an approval step, you pause the tool call before it runs. Your app intercepts the generated SQL string and sends it to a human reviewer. The reviewer checks the exact statement and decides whether to allow or block it. Only approved queries move forward to the database driver.

Database admins also restrict what the agent identity can do after it logs in. In SQL Server, a database user is the identity of a login inside a database. Admins often create a SQL user tied to a login in the master database. For one or a few databases, admins can use a contained database user instead. That user has its own password and does not need a master login. Admins must enable contained databases on the server and database first.

Once the user exists, admins assign it to a fixed database role. The read-only role lets members read all data from all user tables and views. The write role lets members add, delete, or change data in all user tables. Admins can also assign deny roles that block reading or writing across user tables. They avoid the owner role because it can change settings and drop the database.

What native permissions solve and what they leave open

Fixed database roles and app code checks solve the first part of access control. They decide which login can reach the server and which broad actions are allowed. A read-only role stops an agent from dropping tables or deleting rows. A code hook in your app can pause a specific tool call for review.

Approval Chains & Escalation + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, fixed database roles cannot be changed to fit narrow query needs. A read-only role still lets the agent read every user table and view. If a table holds emails, phone numbers, or card numbers, the query returns them. Data masking is needed to rewrite matched fields in results before the model reads them.

App-level approval code also creates maintenance work when you run many agents. Every script needs the same review logic, alert wiring, and audit logging code. Also, the app still holds a static database password in its local settings. Static roles decide who logs in, not what individual statements do in flight. Teams need a way to inspect each query and mask data outside the app code.

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

Can I restrict an agent to read-only queries in SQL Server?

Yes, you can add the database user to the built-in read-only fixed role. You can also add the deny write role to block data changes across tables.

Why is a read-only database role not enough for AI agents?

The read-only fixed role grants read access to all user tables and views. An agent can still pull emails, phone numbers, or national IDs without field masking.

When should I require human approval for agent queries?

You should require approval whenever an agent runs write, update, or delete statements. Many teams also require approval when an agent queries tables with customer records.

The query runs. The emails stay hidden.