How to Configure OpenHands Snowflake Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openhands snowflake audit log by assigning a dedicated service role. Then you read query history views to track every SQL command the agent runs. Engineering teams often use one shared database user for their AI coding agents. This approach makes it hard to see which person triggered a specific query. Overly broad roles also let autonomous agents read sensitive tables or drop production data. A clear audit trail starts with strict role design and built-in account activity views.

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 snowflake audit log by assigning a dedicated service role. Then you read query history views to track every SQL command the agent runs. Engineering teams often use one shared database user for their AI coding agents. This approach makes it hard to see which person triggered a specific query. Overly broad roles also let autonomous agents read sensitive tables or drop production data. A clear audit trail starts with strict role design and built-in account activity views.

How to set up an openhands snowflake audit log

First, create a separate user and a narrow role for the OpenHands agent. Grant this role read privileges only on the schemas required for the current task. Never assign admin roles to an autonomous agent session. When the agent starts a session, it authenticates with this specific role. You can also require the agent to set a session query tag before running commands. This tag attaches a task ID or user email to every single SQL statement.

Next, your security team reads the built-in account usage views to review agent activity. These system views store the text of every query, the active role, and the start time. They also record the rows produced and the warehouse used for each run. You can export these log entries to an external SIEM tool for long-term storage. This setup gives your team a basic record of what the agent did.

What native logging solves and where it falls short

Built-in database logging confirms which role logged in and which SQL statements ran. It helps compliance teams prove that an agent used its assigned service account. It also helps engineers debug failed queries by showing the exact error codes returned. Still, native account history has a known delay before new log rows appear. By the time a bad query shows up in the log, the damage is done.

Native roles decide who logs in, not what individual statements do in flight. Once a role has read permissions on a table, the agent can pull every row by default. An agent might pull thousands of customer emails, phone numbers, or card numbers by mistake. Native logs only tell you that this data leak happened after the query finishes. They cannot pause a dangerous drop command and ask a human for approval first. They also cannot rewrite sensitive fields like national IDs in query results before the agent reads them.

Audit Log Integrity + Snowflake Access Control: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Best practices for tracking AI agent database sessions

Teams can reduce risk by pairing database roles with strict workspace habits. Always run the OpenHands runtime inside an isolated container with zero production keys stored on disk. Rotate the credentials for the agent role on a short schedule. Review your query history views every week to spot unused permissions. If the agent never reads a certain table, revoke that privilege right away.

You should also alert your team when the agent runs queries that scan full tables. Large table scans often mean the agent wrote a bad query or is pulling raw data. Set warehouse timeout rules so a bad agent query cannot run for hours. These steps shrink the blast radius while you build stronger runtime controls.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Have the agent set a unique session tag when it starts a database session. You can then filter the query history view by that exact tag to find all matching commands.

Can native database logs block an agent from reading sensitive columns?

No, audit logs only record queries after they run. To hide sensitive data like emails or card numbers, you need data masking rules that rewrite matched fields in results.

Why do agent queries take time to appear in system audit views?

System usage views process log data in batches rather than in real time. This built-in delay means new query records can take several minutes or more to show up.

The query runs. The emails stay hidden.