How to Configure OpenHands Neon Prevent Delete
To set up openhands neon prevent delete rules, create a restricted Postgres role for your agent. Grant this role select, insert, and update rights, and leave out delete permissions. Teams often give AI coding agents the default database owner role to move fast. Broad permissions let an autonomous agent drop tables or wipe rows by mistake during a task. How openhands neon prevent delete works in Postgres OpenHands runs as an autonomous coding agent that writes code and runs terminal commands.
End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
To set up openhands neon prevent delete rules, create a restricted Postgres role for your agent. Grant this role select, insert, and update rights, and leave out delete permissions. Teams often give AI coding agents the default database owner role to move fast. Broad permissions let an autonomous agent drop tables or wipe rows by mistake during a task.
How openhands neon prevent delete works in Postgres
OpenHands runs as an autonomous coding agent that writes code and runs terminal commands. When the agent builds or fixes an app, it connects to your Neon Postgres branch. By default, Neon gives new projects a main role that owns every schema and table. If OpenHands uses this owner key, it can run any destructive command it chooses.
You can stop row removal by setting up a custom Postgres role inside Neon. First, log in to your database as the admin user. Next, create a new role made just for the OpenHands agent workspace. Grant read, insert, and update access on the target tables to this new role. Do not grant the delete right or table ownership to this agent role.
Neon also lets teams protect whole branches and databases at the platform level. You can turn on branch protection in your Neon project settings to block branch deletion. Combining protected branches with a restricted Postgres role stops both API drops and SQL deletes. After you set up the role, put the new database string into the OpenHands workspace.
Where native database roles fall short for AI agents
Native Postgres roles work well when an agent only needs to read and write data. They block direct delete statements before the database engine can remove a single row. Still, coding agents often need to run schema migrations or clean up test data. A static role cannot tell a safe test cleanup from a bad production delete.
Static database grants only check who logs in and which general command they run. They do not inspect the full query context or check for missing filter clauses. An agent with update rights can still blank out columns across every row in a table. Also, storing raw database keys inside an agent workspace creates a leak risk if prompts fail.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Managing schema changes and safe testing with Neon
To let OpenHands test destructive changes safely, use Neon database branches for each task. A branch gives the agent an isolated copy of your data and schema. You can keep strict delete blocks on your main branch while allowing edits on test branches. Still, teams must check every query before promoting agent code to the main database.
When an agent queries live data to debug an issue, sensitive fields need protection too. Native role grants are all or nothing at the table or column level. If an agent reads a customer table, it sees raw emails, phone numbers, and card numbers. Adding runtime controls helps teams inspect queries, pause risky commands, and mask matched fields in results.
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 overwrite data without delete permissions?
Yes, an agent with update rights can still set existing column values to null or blank. You need query inspection or row-level rules to stop bad updates across a table.
Does Neon branch protection stop SQL delete statements?
No, Neon branch protection only stops users from deleting the branch itself or resetting its data. You must use Postgres role grants or runtime query rules to block SQL delete commands.
How do I let OpenHands run migrations without giving full owner rights?
Run schema migrations in a separate step that requires human approval before execution. Give the OpenHands agent a restricted role for daily coding and testing tasks.
Related guides
In this post