How to Configure OpenHands Neon Read Only Access
You set up openhands neon read only access by creating a restricted database role. Then you pass that role string to the AI agent workspace. Teams often start by sharing the default database owner key during early testing. That wide role lets an autonomous coding agent drop tables or change live rows. Using a restricted role stops the agent from running write queries against your data. How openhands neon read only access works in practice OpenHands runs as an autonomous coding agent inside it
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 openhands neon read only access by creating a restricted database role. Then you pass that role string to the AI agent workspace. Teams often start by sharing the default database owner key during early testing. That wide role lets an autonomous coding agent drop tables or change live rows. Using a restricted role stops the agent from running write queries against your data.
How openhands neon read only access works in practice
OpenHands runs as an autonomous coding agent inside its own workspace container. It writes code, runs shell scripts, and talks to databases to fix bugs. Neon runs serverless Postgres and separates compute nodes from the underlying storage layer. You can limit what the agent does through two native database methods. The first method uses a standard Postgres role with only select rights granted. You create a new database user and grant usage on your target schema. Next, you grant select rights on all current and future tables in that schema. The second method uses a Neon read replica compute endpoint for the agent. A read replica node rejects all write queries at the compute layer itself. You give the agent the replica connection string through its workspace variables. The agent then reads schema states and sample rows without changing your primary data. Both approaches rely on native Postgres and Neon features to block write actions.
Where native read roles fall short for AI agents
Native database roles and read endpoints stop an agent from altering stored records. They check who logs in and block write statements at the database engine. Still, native roles do not inspect what individual select queries return in flight. A read role still lets the agent pull every row from sensitive customer tables by default. When the agent runs a query, raw emails and phone numbers enter its context. Those sensitive values also land in agent workspace files and third party model logs. Dynamic data masking solves this problem by rewriting matched fields in query results. It swaps card numbers and national IDs with safe tokens before the agent reads them. Also, a static connection string inside the agent workspace carries long term risk. If a prompt causes the agent to print its variables, that database secret leaks. Native roles also lack fine grained query rules for complex agent tasks. A single bad query from an agent can still scan millions of rows. Even on a read replica, huge table scans can spike compute bills fast. Teams need a way to inspect every query and mask sensitive fields in flight.
How to manage database branches and agent tasks
Many teams pair read roles with isolated database branches for agent testing. Neon lets you fork a database branch when an agent starts a task. The agent can test schema changes on the branch while reading from main. Yet branches made from live data still hold real emails and card numbers. You still must protect those sensitive columns before the agent runs a query. You also need clear audit logs that tie each query to a user. Standard database logs only show the shared role name used by the agent. They do not show which developer started the agent run or why. Pairing database roles with query level controls fixes both audit and data gaps.
Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Run guardrails and masking on the Postgres connection
Role grants and firewall rules are needed setup. Setup alone cannot check single SQL statements or mask sensitive rows in a response. By design, hoop.dev is an open-source proxy that sits beside Postgres, RDS, or Aurora as a sidecar for your Postgres. Clients and agent tools keep their credentials and point their connection string at the listener.
On each query, hoop.dev guardrails refuse disallowed drops, deletes, or table reads before they run. Next, hoop.dev data masking rewrites sensitive fields in returned rows that match your rules. Furthermore, hoop.dev holds SOC 2 Type II and logs every statement and verdict per resource. Check out the project on GitHub.
Frequently asked questions
Can OpenHands still drop tables with a read only Postgres role?
No, a proper read role blocks all drop, delete, update, and insert commands. You must also revoke create rights on the public schema for that user.
Does a Neon read replica hide sensitive customer data from the agent?
No, a read replica has the exact same data as your primary branch. To hide emails or card numbers, you must rewrite matched fields in results.
Should I put the database password in the agent workspace file?
Storing plain passwords in agent files creates a leak risk during long runs. It is safer to keep credentials outside the workspace where the agent runs.
Related guides
In this post