How to Configure OpenHands Neon Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openhands neon audit log by turning on Postgres logging extensions in your Neon branch. Then you give your OpenHands agent a dedicated database role so the log tracks its work. Most teams start by sharing one broad admin role with the coding agent. This quick shortcut creates big risks when the agent runs bad queries or drops tables. How the openhands neon audit log works OpenHands runs as an autonomous coding agent inside its own workspace container. It reads your code, plans 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.

You set up an openhands neon audit log by turning on Postgres logging extensions in your Neon branch. Then you give your OpenHands agent a dedicated database role so the log tracks its work. Most teams start by sharing one broad admin role with the coding agent. This quick shortcut creates big risks when the agent runs bad queries or drops tables.

How the openhands neon audit log works

OpenHands runs as an autonomous coding agent inside its own workspace container. It reads your code, plans changes, and runs commands to finish tasks. When a task needs database changes, the agent connects to your Neon Postgres branch. It uses standard database keys stored in its workspace settings.

Neon runs serverless Postgres and supports standard database logging extensions. To build an openhands neon audit log, you turn on the audit extension in your database. You then set rules to record reads, writes, and schema changes. The database writes these events to its internal log stream as they happen.

For clean records, you must create a separate Postgres role just for OpenHands. If the agent shares a login with a human developer, the log mixes their work. A dedicated role tags every agent query with one clear username. Your security team can then filter the Neon logs to review what the agent ran.

Why native roles and logs are not enough

Giving OpenHands its own database role solves basic tracking problems. You can see when the agent logged in and which tables it touched. You can also limit the role so it only reads from certain schemas. This stops some mistakes before they break your main database branch.

Still, native database roles and logs leave a major operational gap open. A database role only checks who logs in at the start of a session. It does not check the safety of each query while it runs in flight. If the agent has write permissions, it can still run a bad delete statement.

Native audit logs also only tell you about a mistake after it happens. The log records that the agent read sensitive customer data, like emails or phone numbers. By the time you read the log, those fields are already in the agent context. Masking tools that rewrite matched fields in results are not part of a basic log setup.

Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing agent database keys and runtime rules

Putting raw database keys inside an OpenHands container creates another security risk. The agent can read its own workspace files and print those keys in chat logs. If a prompt tricks the agent, it might send those keys to an outside server. Rotating those keys by hand across many branches takes a lot of team time.

Database roles are also static and hard to tune for every single task. One ticket might need a schema change, while the next only needs a simple read. Updating Postgres grants before every agent run slows down your whole engineering team. Because of this friction, teams often leave broad permissions on all the time.

To stay safe, teams need a way to check every query before it hits Neon. You want to pause risky schema changes and wait for a human to approve them. You also want to rewrite sensitive fields like card numbers or national IDs in query results. Combining real-time query checks with your audit log keeps both your data and your team safe.

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

Does Neon keep audit logs forever by default?

No, Neon only keeps system logs for a limited window based on your plan. To save audit records for months, you must export them to an outside log store.

Can OpenHands change its own database permissions?

If you give the agent a superuser or admin role, it can change its own grants. Always give the agent a restricted role that cannot alter roles or audit settings.

How do I tell agent queries apart from human queries in Neon?

Create a dedicated Postgres user role for OpenHands and use it only for agent tasks. Every line in the audit log will then show that specific role name.

The query runs. The emails stay hidden.