How to Configure OpenHands CockroachDB Connect
You set up an openhands cockroachdb connect workflow by giving the agent a database role and login string. The agent then uses standard Postgres drivers to run SQL queries inside its container. Engineering teams often use a single shared account to get the agent running fast. This broad role lets the autonomous agent alter tables or read sensitive rows by mistake. How an openhands cockroachdb connect setup works OpenHands runs tasks inside an isolated workspace container. The agent writes cod
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 openhands cockroachdb connect workflow by giving the agent a database role and login string. The agent then uses standard Postgres drivers to run SQL queries inside its container. Engineering teams often use a single shared account to get the agent running fast. This broad role lets the autonomous agent alter tables or read sensitive rows by mistake.
How an openhands cockroachdb connect setup works
OpenHands runs tasks inside an isolated workspace container. The agent writes code, runs shell scripts, and talks to external data stores. CockroachDB uses the standard Postgres wire protocol for client traffic. This means the agent can use normal database tools to talk to your cluster.
First, an admin creates a dedicated SQL user inside the database cluster. You assign specific table privileges to this new role. Next, you generate a client certificate or a strong password for the account. You also need the cluster root certificate to verify the TLS link.
Then, you pass these credentials into the agent workspace as secret variables. The agent reads the host address, port, user name, and secret key from its workspace. When the user gives the agent a prompt, the agent starts a database session. It sends SQL commands over the network and reads the returned rows to plan its next step.
Network rules and role limits for autonomous agents
Autonomous agents try many commands to solve a single coding problem. If a query fails, the agent often guesses a new query and runs it right away. You must lock down the database role before the agent starts work.
Grant read privileges only on the specific tables the agent needs to inspect. Do not give the agent admin rights or table drop permissions in production. You should also set network allowlists so the cluster only accepts traffic from the agent host.
Timeouts and resource limits also matter for AI workloads. An agent might write a bad join that scans millions of rows at once. Setting statement timeouts on the database user stops bad queries from slowing down the cluster. You can also cap the number of open sessions for that specific role.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native database roles solve and what they miss
Native database roles and network rules handle the first step of security. They check who can log in and which tables that account can touch. TLS encryption keeps the data safe as it moves across the network. Role grants stop a read-only agent from deleting a whole schema.
Still, static roles leave a big gap during live agent runs. Once the agent logs in, the database trusts every valid query that matches the role grants. Native roles cannot check the intent of an individual SQL statement in flight. You cannot require a human to approve a single risky update while letting safe reads pass.
Also, static database roles do not mask sensitive columns on the fly. If an agent queries a customer table, the database returns raw emails, phone numbers, and card numbers. Those sensitive fields go straight into the model prompt history and external API logs. Database audit logs also show only the shared agent user name, not the human who started the task.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
How does OpenHands talk to a CockroachDB cluster?
The agent runs inside a container and uses standard Postgres client libraries. It reads the cluster host and login keys from its workspace variables to open a TLS session.
Why are static database passwords risky for AI coding agents?
Agents run shell scripts and read workspace files on their own. If a secret key sits in the workspace, a bad prompt or log dump can expose that credential.
How can teams protect sensitive data during agent database tasks?
Teams should restrict the agent to a tight role and require approval for write queries. Adding data masking rewrites matched emails, phone numbers, and national IDs in query results.
Related guides
In this post