How to Configure OpenHands Postgres Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up openhands postgres prevent delete rules, create a dedicated database role. Grant that role read and write rights while withholding the delete privilege. Engineering teams often give coding agents broad database credentials to speed up work. When an AI agent holds full table rights, one bad query can wipe out records. How openhands postgres prevent delete works with native roles OpenHands runs as an autonomous coding agent that executes commands and database queries. When the agent c

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 openhands postgres prevent delete rules, create a dedicated database role. Grant that role read and write rights while withholding the delete privilege. Engineering teams often give coding agents broad database credentials to speed up work. When an AI agent holds full table rights, one bad query can wipe out records.

How openhands postgres prevent delete works with native roles

OpenHands runs as an autonomous coding agent that executes commands and database queries. When the agent connects to PostgreSQL, the database checks the privileges of its role. PostgreSQL manages table actions through distinct grants for reading, inserting, updating, and deleting data. To block row removal, admins create a specific group role for the agent. They grant membership in this group role to the agent user account.

Next, the database owner grants select, insert, and update privileges on target tables. The select privilege allows reading from any column or specific columns of a table. It also allows copying data out of the table. By leaving out the delete privilege, PostgreSQL rejects any delete statements from the agent. Admins must also check the special role named PUBLIC. By default, PUBLIC gives every role on the system the right to run functions. It also grants the right to connect and make temporary tables on databases. An object owner can revoke these default grants if functions remove data.

Schema rules also affect what an autonomous agent can do inside the database. In PostgreSQL 15 and later, default settings block users from creating public schema objects. In older versions or upgraded databases, an admin must revoke create rights from PUBLIC. This stops the agent from building new objects that bypass table rules. When teams create new tables later, they must update role grants each time. Default privileges only apply to objects created by the specific user who set them.

What native grants solve and what they leave open

Native database roles work well to enforce basic table boundaries at login time. If OpenHands sends a direct delete query, the database engine blocks it right away. This setup protects core tables from simple mistakes during automated coding tasks. It also helps teams group permissions when many users or agents share the database.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static database roles only check who logs in and which table they touch. Native grants cannot inspect what individual statements do in flight. An agent with update rights can still overwrite every row with blank values. That action destroys data just like a delete command, yet the database allows it. Native roles also cannot require a human to approve a risky update query first.

Column grants have limits too when sensitive records live in those same tables. While admins can grant select on specific columns, managing column lists across tables takes work. If a table holds emails, phone numbers, card numbers, or national IDs, broad select grants expose them. Data masking rewrites matched fields in results without breaking queries that need the column. Static roles also store long-lived passwords inside the agent workspace, where prompts might leak them.

Add query and result controls beside Postgres

Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev runs beside your database as a sidecar for your Postgres. It reads plain and prepared queries on the wire with no change to your users or drivers.

When a tool or agent sends SQL, hoop.dev Postgres controls check each statement against your deny rules. An AI Analyzer you configure can also score intent or hold a risky query for human review. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.

Frequently asked questions

Can PostgreSQL block delete statements without making the role read-only?

Yes, PostgreSQL separates table privileges by action. You can grant select, insert, and update rights on a table while omitting delete rights.

Why can an OpenHands agent still run functions that delete rows?

The special PUBLIC role grants execute rights on functions and procedures to every role by default. If a function has owner privileges, the agent can run it unless you revoke execute rights.

Do no-delete table grants protect against destructive update queries?

No, native update privileges let a role change any column value in any row. An agent can still null out records or overwrite whole tables without a where clause.

The query runs. The emails stay hidden.