How to Configure LangChain CockroachDB Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a langchain cockroachdb approval step by pausing the agent before SQL runs. A human or rule checks the query and lets the database tool run it. Teams often link an AI agent straight to a database with a shared login key. When that database role has broad rights, one bad prompt can change or drop tables. Putting a review step in front of the database stops unsafe queries before they run. How to set up a langchain cockroachdb approval flow An AI agent takes a question in plain text a

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 a langchain cockroachdb approval step by pausing the agent before SQL runs. A human or rule checks the query and lets the database tool run it. Teams often link an AI agent straight to a database with a shared login key. When that database role has broad rights, one bad prompt can change or drop tables. Putting a review step in front of the database stops unsafe queries before they run.

How to set up a langchain cockroachdb approval flow

An AI agent takes a question in plain text and turns it into SQL queries. The agent then runs those queries and shows the results to the user. Because CockroachDB uses the Postgres wire protocol, standard Postgres database tools work with it. First, you create a dedicated database role in CockroachDB with strict table permissions. You should only grant read permissions on the specific tables the agent needs to check. If the agent must write data, limit that role to specific rows and columns.

Next, you add a pause step inside your agent workflow before the database tool runs. When the model builds a SQL statement, the workflow stops and saves its current state. The app then sends the pending query to a team chat channel or review screen. A team member reads the exact SQL text and clicks approve or reject. Once approved, the agent resumes its run and sends the query to the database.

What native roles and app checks leave open

Database roles and app review steps solve the basic login problem for AI tools. The database role decides which tables the agent login can read or write. The app pause step lets a person check a tool call inside that specific app. Still, this setup only governs who logs in and what one app decides to pause.

Native roles do not look at individual queries while they are in flight. A read role still lets an agent pull a whole table full of customer records. That query result might include raw emails, phone numbers, card numbers, or national IDs. Also, building pause steps into every single agent script takes a lot of time. If a developer forgets to add the check in one workflow, queries run without review. You also lack one central log that links the user prompt to the database query. When multiple agents share one database role, the database log only shows that shared role.

Approval Chains & Escalation + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to make query reviews and data masking work

To keep production data safe, teams need controls that check every single SQL statement. Good review rules should trigger based on the actual SQL command, not just the app. For example, simple read queries on safe tables can run right away without waiting. Queries that update rows or touch sensitive tables should pause for a human to approve.

You also need data masking that rewrites matched fields in results before the agent reads them. Masking replaces emails, phone numbers, and card numbers with placeholders in the query output. This keeps sensitive strings out of the language model context window and third-party model logs. Strong workflows pair least-privilege CockroachDB roles with statement checks and result masking.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why do AI agents need query approval on CockroachDB?

Language models turn plain text into SQL and can write bad or destructive queries. An approval step lets a human check high-risk SQL statements before they hit your database.

Can a read-only CockroachDB role replace an approval workflow?

A read-only role stops data changes, but it does not stop broad data dumps. An agent can still run heavy queries or pull sensitive fields like emails and card numbers.

Which agent queries should require human approval?

Teams usually require approval for any query that writes, updates, or deletes database rows. You should also review queries that read tables with customer records or billing details.

The query runs. The emails stay hidden.