How to Configure OpenAI Agents SDK ClickHouse Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openai agents sdk clickhouse approval by pairing database roles with human checks. The agent prepares a query and waits for a reviewer before running it. Many teams start by giving their agent a broad database account. That shortcut lets a model read private tables or run heavy queries by mistake. A safer setup combines strict database rights with a clear review step in your app. How openai agents sdk clickhouse approval works with database roles First, you lock down what the agent

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 clickhouse approval by pairing database roles with human checks. The agent prepares a query and waits for a reviewer before running it. Many teams start by giving their agent a broad database account. That shortcut lets a model read private tables or run heavy queries by mistake. A safer setup combines strict database rights with a clear review step in your app.

How openai agents sdk clickhouse approval works with database roles

First, you lock down what the agent account can touch inside the database. ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. Turning on SQL-driven control takes a storage directory on the server. It also needs at least one admin user with access management turned on. That admin can only grant privileges that they hold themselves. When creating the agent user, you set its login method and allowed client hosts. You also assign default roles and per-user settings during user creation.

Next, you limit which columns the agent role is allowed to read. ClickHouse lets you grant read rights on specific columns of a table. If an agent only has rights on two columns, it can query only those two. A query asking for a third column will fail right away. A wildcard query across all columns is also refused and returns no data. The wildcard query only works if the table holds just the granted columns. Since version 24.10, a trailing asterisk grants rights by table name prefix.

How agent tool calls pause for human review

Database roles block bad tables, but they do not review the logic of a query. An agent runs in a loop where the model picks a tool and sends inputs. In a database tool, that input is often a generated SQL statement. Before your tool code sends that statement to the database, your app can pause the run. The app sends the proposed query text to a human reviewer in chat or email.

The reviewer reads the SQL statement and checks the tables and filters. If the reviewer approves the request, the tool runs the query and returns the rows. If the reviewer rejects it, the tool returns a clear denial message to the agent. The agent can then adjust its query and ask for approval again. This flow stops unreviewed writes or wide scans before they hit the cluster.

Approval Chains & Escalation + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles and app checks leave open

Native database roles and app-level checks solve two big problems, but gaps remain. Database roles decide who logs in and which tables or columns they can read. They do not inspect what each statement does in flight or why it ran. If a role has write rights for one task, every tool call shares that power. Also, if a table holds emails, phone numbers, card numbers, or national IDs, a permitted read returns them raw.

App-level review prompts also have blind spots across a growing team. Each developer has to build the pause logic inside every custom database tool. If an engineer forgets to add the check on a new tool, queries run without review. Also, database logs only record the shared service account name, not the human who approved the run. Teams need a consistent way to inspect queries, rewrite matched sensitive fields in results, and log approvals.

Check ClickHouse queries and result columns on the wire

ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.

Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.

Frequently asked questions

Can ClickHouse restrict an agent to specific columns?

Yes, you can grant read rights on specific columns in a table. Queries that request other columns or use a wildcard across ungranted columns will be refused.

Why do read-only agent queries still need approval?

Even a read-only query can scan huge tables or pull sensitive customer columns. A human review step checks that the query is safe and needed before it runs.

What happens when an agent runs a wildcard select on a restricted table?

ClickHouse refuses a wildcard select and returns no data unless the user has rights on every column in that table.

The query runs. The emails stay hidden.