How to Configure LangChain ClickHouse Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a langchain clickhouse approval workflow, pause agent database calls for human review. You also pair that review step with strict database user roles. Most teams first link an AI agent straight to an analytical database. They give the agent a shared login key so it can answer data questions. When that role has broad permissions, one bad prompt can expose private rows. It can also trigger heavy scans that slow down the whole cluster. How a native langchain clickhouse approval setup wo

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 a langchain clickhouse approval workflow, pause agent database calls for human review. You also pair that review step with strict database user roles. Most teams first link an AI agent straight to an analytical database. They give the agent a shared login key so it can answer data questions. When that role has broad permissions, one bad prompt can expose private rows. It can also trigger heavy scans that slow down the whole cluster.

How a native langchain clickhouse approval setup works

In an agent framework, a chat model links to one or more database tools. The model reads a user question and picks which tool to call. It then turns the question into a SQL query and tries to run it. By default, the agent runs the query as soon as the model writes it. To add an approval step in code, developers wrap the database tool in a pause check. When the agent drafts a query, the app holds the state and sends an alert. A human reviewer reads the SQL text and clicks approve or reject. Only after approval does the app send the query to the database.

On the database side, teams pair this app check with SQL access rules. ClickHouse treats users, roles, row policies, settings profiles, and quotas as access items. Admins create these items with SQL once a storage folder is set up. At least one admin account needs access management rights turned on. That admin can only grant rights that they already hold themselves. When creating a user for an agent, the admin sets the login method. They also set allowed source hosts, default roles, and user settings.

How column grants limit what the agent reads

Even with human review, an agent should not hold full table read rights. ClickHouse lets admins grant read access on single columns in a table. If an agent user only has rights on two columns, it can query those two. Any query asking for a third column will fail right away. A full wildcard query on that table also fails and returns no data at all. It only works if the table holds just the allowed columns. Admins can also grant read rights across tables that share a name prefix. This keeps the agent away from tables that hold sensitive business records.

What native setup solves and what it leaves open

Combining app pause checks and database roles fixes basic login risks. The database checks who logs in and which columns or hosts they can use. The app check lets a person spot bad queries inside that single app. Yet this two-part setup leaves big gaps in daily work.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

First, app code checks only guard one script or service. If another team builds a second agent, they must rebuild the whole review flow. If a developer skips the wrapper in a test script, queries run without review. Second, static column grants are hard to keep up to date as schemas change. If a allowed column holds emails, phone numbers, card numbers, or national IDs, raw values return. Database grants decide if a role can read a column, not how to mask fields. Third, database roles decide who logs in, not what each statement does in flight. A reviewer reading raw SQL in a chat alert lacks context on cluster load. Teams need a unified way to check every query and mask sensitive fields in results.

Check ClickHouse queries and results before execution

Access control in ClickHouse is essential setup. Setup alone does not check single queries for risk or rewrite sensitive strings in returned rows. By design, hoop.dev sits beside the server as a sidecar for your ClickHouse and parses every statement before execution.

First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations. Then hoop.dev data masking rewrites sensitive string columns in responses and logs each decision per resource. Read the docs and source on GitHub.

Frequently asked questions

Can an agent run a wildcard query when given column-level grants?

No, a wildcard select fails and returns no data when some columns are restricted. The wildcard query only works if the table holds just the granted columns.

Why are database roles not enough for AI agent safety?

Database roles check who logs in and which tables or columns they can touch. They do not pause risky queries for human sign-off or rewrite emails in results.

How does ClickHouse manage roles and quotas for agent accounts?

ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL statements. An admin sets up a storage path and assigns default roles and host limits.

The query runs. The emails stay hidden.