How to Configure OpenAI Agents SDK MariaDB Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openai agents sdk mariadb approval by pausing tool runs before SQL executes. A human or rule checks the query text before the app sends it to MariaDB. Teams often start by giving an agent a single database user with broad table rights. When that role is too wide, one bad prompt can drop tables or leak data. How openai agents sdk mariadb approval works in practice In the OpenAI Agents SDK, you build Python functions and hand them to the model. The model reads the user request and de

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 mariadb approval by pausing tool runs before SQL executes. A human or rule checks the query text before the app sends it to MariaDB. Teams often start by giving an agent a single database user with broad table rights. When that role is too wide, one bad prompt can drop tables or leak data.

How openai agents sdk mariadb approval works in practice

In the OpenAI Agents SDK, you build Python functions and hand them to the model. The model reads the user request and decides which tool function to call next. To query MariaDB, a developer writes a tool that opens a normal database session. The model creates the SQL string and passes it into that Python function.

Without a check step, the function runs the query right away and returns the rows. To add an approval flow, the developer changes how that Python tool behaves at runtime. Instead of running the SQL right away, the function saves the pending query to state. The app then pauses the agent run and sends a note to a reviewer.

A team member reads the SQL text in a chat app or a dashboard. If the reviewer clicks approve, the app resumes the function and runs the query. If the reviewer clicks reject, the function returns an error message back to the model. Teams also link this flow with strict MariaDB user roles to limit table access.

What native setups solve and what they leave open

Building a check inside your Python code stops obvious bad writes when a human watches. Database roles also help by blocking the agent from tables it should never touch. Setting a read-only role in MariaDB stops the agent from deleting rows by mistake.

Yet this homegrown setup leaves big gaps when you run many agents at scale. Native database roles only check who logs in at the start of a session. They do not inspect what each single query tries to do in flight. A read role still lets an agent pull a million rows of customer phone numbers.

Approval Chains & Escalation + OpenAI API Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

App-level review code is also hard to keep safe across many different code repos. Every developer must write the exact same pause and check logic in every new tool. If one person forgets that wrapper, the agent gets direct access to the database again. Also, your app still holds raw database passwords in memory to open the session.

Why query-level checks and data masking matter for agents

Reviewing every single SELECT query by hand slows down the whole team very fast. Reviewers get tired and start clicking approve without reading the full SQL statement closely. A better setup separates safe read queries from risky commands that change data or schemas. Routine reads can pass through while table changes pause for a quick human sign-off.

Even safe read queries need a filter before results go back to the model. Customer tables often hold sensitive fields like emails, card numbers, and national IDs. When the agent runs a query, those values travel back to the external model API. Rewriting matched fields in results keeps private data out of prompts and third-party logs.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL. It runs next to MySQL, RDS, or Aurora and reads the MySQL wire protocol.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails. When a rule refuses a query, MySQL returns a native error packet with your message. On the response path, hoop.dev data masking rewrites string values in returned rows that match your rules. Every query and decision is logged per resource. See the MIT-licensed project on GitHub.

Frequently asked questions

Can an OpenAI agent run SQL on MariaDB without human review?

Yes, if you give the agent a direct database tool, it runs queries right away. You must add a check step if you want to pause risky statements first.

Do read-only MariaDB roles stop private data leaks to the model?

No, a read-only role only stops the agent from changing or deleting table data. The agent can still read emails, phone numbers, or card numbers and send them out.

Which agent queries should require a human approval step?

Teams usually pause any query that alters tables, deletes rows, or changes user rights. You can also pause wide read queries that try to pull whole customer tables.

The query runs. The emails stay hidden.