How to Configure OpenAI Agents SDK CockroachDB Approval
To set up an openai agents sdk cockroachdb approval workflow, you wrap database tools with human review checks and use scoped database roles. You pause the agent run before it sends any write or schema change to the cluster. Many engineering teams start by giving their agent a standard database user account. When that role has broad permissions, a bad prompt can change or delete production tables. How openai agents sdk cockroachdb approval works in practice An agent built with this framework
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 an openai agents sdk cockroachdb approval workflow, you wrap database tools with human review checks and use scoped database roles. You pause the agent run before it sends any write or schema change to the cluster. Many engineering teams start by giving their agent a standard database user account. When that role has broad permissions, a bad prompt can change or delete production tables.
How openai agents sdk cockroachdb approval works in practice
An agent built with this framework uses custom tool functions to talk to your database. The model reads the user request and decides which database tool to call next. It then builds a SQL query string based on the table schema it knows.
Without an approval step, the tool function runs that SQL string right away. The database driver opens a session to CockroachDB using a stored user key. The cluster checks the role permissions for that account and runs the statement.
To add human review in your app code, you split the tool into two steps. First, the agent drafts the SQL query and sends it to a review queue. The agent run pauses and waits for a person on your team to check it. A reviewer reads the SQL text in Slack or an internal web app. If the reviewer clicks approve, the app resumes the run and sends the query. If the reviewer denies the request, the tool returns an error message to the model.
What native roles and app checks leave open
CockroachDB gives you role-based controls to limit what a database user can do. You can create a read-only role for safe lookups and a write role for updates. This native setup decides who can log in and which tables they can touch.
Still, static database roles cannot check the intent of a single query in flight. If an agent needs to update one customer row, its role must allow table updates. That same permission lets a confused model update every row in the table at once by default.
Building approval queues inside your own agent code also creates extra work for your team. Every developer must write and maintain the same pause and resume logic in each app. If someone forgets to wrap a new tool function, the agent bypasses the review step.
Approval Chains & Escalation + OpenAI API Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
App-level checks also miss what comes back from the database after a query runs. A safe select query can still pull sensitive emails, phone numbers, or card numbers. Data masking is needed to rewrite matched fields in results before the model reads them.
Separating read tools from write tools
A good design splits your agent database tools by risk level from day one. Give the agent one tool for read queries and another tool for write queries. Point the read tool at a database role that only has select permissions.
Keep the write tool behind a strict human check so every state change gets reviewed. You can also limit the write tool to specific tables or safe stored procedures. This stops the model from inventing dangerous commands like dropping a table or changing roles.
Even with split tools, you still need a central log of every query that runs. Database logs only show the shared app user name, not which agent run sent it. Tying each SQL statement back to a specific user request makes audits much faster.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Why should we approve SQL queries generated by an AI agent?
Language models can misread a prompt and write a query that deletes or alters rows. Reviewing the statement before it runs stops bad writes from hitting your production tables.
Can CockroachDB roles replace an approval workflow for agents?
No, database roles only check table permissions at the account level. They cannot pause a single risky update statement and ask a human to check it.
How do we keep sensitive data out of agent prompts?
You can apply data masking to rewrite emails, phone numbers, and national IDs in query results. This keeps real personal details out of the model context while preserving the row format.
Related guides
In this post