How to Configure OpenHands CockroachDB Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an openhands cockroachdb sandbox, give the agent container a restricted database user. Then point the agent runtime to an isolated test cluster over encrypted network ports. Engineering teams use this setup so autonomous coding agents can build and test schema changes. Most teams start by handing the agent a broad admin role to move fast. Broad permissions let an AI agent drop tables or read sensitive rows by mistake. How the openhands cockroachdb sandbox architecture works OpenHand

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 an openhands cockroachdb sandbox, give the agent container a restricted database user. Then point the agent runtime to an isolated test cluster over encrypted network ports. Engineering teams use this setup so autonomous coding agents can build and test schema changes. Most teams start by handing the agent a broad admin role to move fast. Broad permissions let an AI agent drop tables or read sensitive rows by mistake.

How the openhands cockroachdb sandbox architecture works

OpenHands runs inside an isolated container where the AI agent writes code and runs commands. When the agent builds database features, it needs a live SQL target to test queries. A CockroachDB sandbox cluster gives the agent a safe place to run those tests. Because CockroachDB speaks the standard PostgreSQL wire protocol, the agent uses common client drivers.

To link the two systems, engineers create a dedicated SQL role inside the database cluster. You grant this role permission to read and write only inside one specific test schema. Next, you pass the database host address and role credentials into the agent workspace. The agent reads these values from its local runtime variables when it starts a task.

Good sandbox design keeps the agent away from production networks and real customer data. Teams place the test cluster in a separate virtual network with strict firewall rules. The container can reach the database port, but it cannot reach other internal services. You also load synthetic data into the tables so the agent can test realistic queries.

What native database roles solve and what they miss

Native SQL roles inside the database cluster do a great job of limiting schema access. You can block the agent role from creating new databases or changing cluster settings. You can also restrict the role so it only sees tables inside its own sandbox. If the agent tries to query another database, the engine rejects the command right away.

Still, static database roles only check who logs in at the start of a session. They do not inspect what individual statements or commands do while the agent works. Once the agent logs in with a write role, it can still run destructive queries. A confused model loop might delete all rows in the test table and break tests.

AI Sandbox Environments + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static credentials inside the agent container also create a secret management problem for your team. Because the agent can run shell commands, it can read its own local variables. A bad prompt or a model error could print the database password into build logs. In shared staging clusters, real emails, phone numbers, or card numbers often slip into test tables. Native roles return all rows in full instead of rewriting matched fields in results by default.

Best practices for safe agent database testing

Start every agent task with a clean schema state so failed runs do not linger. Teams often run a quick reset script before the agent container begins its coding loop. Keep the test data set small so runaway joins do not exhaust cluster memory. Set statement timeouts on the database role so slow queries fail fast and free resources.

Review the SQL queries the agent runs during each coding session to spot bad patterns. Autonomous agents often write extra queries when they try to fix a failing test. Tracking every statement tied to a specific task helps engineers debug bad code changes fast. Pair your native database roles with statement controls and field masking for safer agent workflows.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can OpenHands use standard PostgreSQL tools with a CockroachDB sandbox?

Yes, CockroachDB supports the PostgreSQL wire protocol out of the box for client apps. The agent can use standard PostgreSQL drivers and command line tools to run queries.

Why should teams avoid giving admin database roles to coding agents?

Autonomous agents run commands in a loop and can make mistakes when fixing code bugs. An admin role lets a bad command drop schemas or change cluster settings without warning.

How do you protect sensitive test data during agent runs?

Use synthetic test records whenever possible so real customer details stay out of the sandbox. If staging data has emails or phone numbers, use data masking to rewrite matched fields.

The query runs. The emails stay hidden.