How to Configure OpenAI Agents SDK MariaDB Sandbox
You set up an openai agents sdk mariadb sandbox by pairing a read-only database role with a tool function. The agent calls this Python function to run queries against an isolated database copy. Teams often start by handing the agent a shared login for testing. If that login has broad rights, one bad prompt can drop tables or leak data. How an openai agents sdk mariadb sandbox works The agent framework uses Python functions as tools to talk to external systems. You write a short function that
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 an openai agents sdk mariadb sandbox by pairing a read-only database role with a tool function. The agent calls this Python function to run queries against an isolated database copy. Teams often start by handing the agent a shared login for testing. If that login has broad rights, one bad prompt can drop tables or leak data.
How an openai agents sdk mariadb sandbox works
The agent framework uses Python functions as tools to talk to external systems. You write a short function that opens a database session and runs a query. The language model reads the user prompt and decides when to call that function. It writes a SQL string and passes that string into your tool.
To build the sandbox, you first spin up a separate database instance. You load this instance with safe test rows or synthetic records. Next, you create a dedicated database user just for the agent. You grant this user permission to read specific tables and block all write actions.
Your Python app holds the login key for that restricted database user. When the agent runs, it uses that single login for every tool call. The database checks the user role when the session starts. If the model tries to delete a row, the database role blocks the write.
Why database roles and sandboxes fall short
A sandbox stops an agent from breaking your live system during early tests. A read-only role also stops the model from changing or deleting your data. These native steps solve the problem of who can log into the database. They do not inspect what each query does once the session is open.
First, teams move agents from test sandboxes to real data to get real value. Once the agent reads real tables, a read-only role still lets it pull every row by default. If a table holds customer emails or card numbers, the query returns them in plain text. Masking rewrites matched fields in results so raw emails or phone numbers do not reach the model.
Second, all agent queries share the exact same database login. Your database logs only show that the app account ran a statement. You cannot tell which user prompt or agent task triggered a bad query. Native database roles also cannot pause a risky query to ask a human for approval.
AI Sandbox Environments + OpenAI API Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
How to tighten agent database sessions
Start by trimming the schema context you give to the model. Only show the agent the exact tables and columns it needs for its task. Hiding internal system tables keeps the model from guessing sensitive column names.
Next, set strict row limits and short time limits on every database session. Models often write bad joins that scan millions of rows by mistake. A strict time limit kills runaway queries before they lock up your database server. Keep your database credentials in a secure store instead of plain text files.
Finally, log the full prompt alongside the SQL query the model wrote. Linking the user request to the database statement helps your team fix bad prompts fast. It also gives your security team a clear trail during an audit.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.
With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
Can an agent run write queries in a MariaDB sandbox?
Yes, if the database role allows writes, the agent can insert or delete rows. You should give the agent a read-only role unless its job requires writing data. If writes are needed, limit permissions to one specific table.
How do I stop an agent from reading sensitive columns?
In a basic setup, you can create database views that leave out private columns. You then grant the agent role access only to those safe views. For live tables, data masking rewrites fields like national IDs or card numbers in query results.
Why did my agent query lock up the sandbox database?
Language models often write queries without row limits or proper table indexes. When the tool runs that query, the database scans the whole table at once. Set a short query timeout on the database role to stop slow queries right away.
Related guides
In this post