How to Configure OpenHands Bigquery Guardrails

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands bigquery guardrails by pairing scoped cloud roles with query limits. You also add column tags and row rules to limit what the agent reads. Many engineering teams start by giving their coding agent a broad project role. That shortcut lets the agent run any query across every table in the project. A bad prompt or agent loop can then drop tables or rack up huge bills. How to set up native openhands bigquery guardrails Start by creating a dedicated service account just for yo

BigQuery IAM + AI Guardrails: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up openhands bigquery guardrails by pairing scoped cloud roles with query limits. You also add column tags and row rules to limit what the agent reads. Many engineering teams start by giving their coding agent a broad project role. That shortcut lets the agent run any query across every table in the project. A bad prompt or agent loop can then drop tables or rack up huge bills.

How to set up native openhands bigquery guardrails

Start by creating a dedicated service account just for your OpenHands agent runs. Do not let the agent share keys with human engineers or other apps. Grant this account read permissions on the specific datasets it needs for its tasks. Avoid project-wide roles because they open up every dataset in your cloud workspace.

Next, set up cost rules inside your cloud project to stop runaway spending. BigQuery lets you cap the bytes scanned per query and per day for each project. When the agent writes a bad join across a huge table, the query fails fast. This simple rule keeps a stuck agent loop from draining your monthly cloud budget.

You should also add policy tags to columns that hold private customer records. Policy tags let you restrict who can read fields like emails and phone numbers. If you need to filter rows by region, add row access rules to those tables. The agent will only receive rows that match its assigned service account role.

Why static cloud roles fall short for AI agents

Cloud roles and dataset rules check who logs in when a session starts. They do not inspect the actual SQL text that the agent sends in flight. Once a service account passes the role check, every allowed query runs without pause. If the agent needs write permissions to fix data, it can alter any allowed row.

Static policy tags also work as an all-or-nothing block on private columns. If a query touches a blocked column, BigQuery rejects the whole statement right away. That stops the agent from testing queries on tables that mix public and private fields. Teams often remove the tag to unblock the agent, which exposes raw card numbers.

BigQuery IAM + AI Guardrails: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Service account keys also create a storage risk inside the agent container workspace. OpenHands executes shell commands and reads files inside its local sandbox during a task. If you mount a static key file there, a bad prompt could read that file. Managing those keys across many agent runs adds extra manual work for your team.

Evaluating query rules and field masking in flight

A strong safety setup checks every query statement before it reaches the data warehouse. Instead of blocking a whole table, runtime rules inspect the command type in real time. You can allow select queries to run while holding delete statements for human approval. This gives the agent room to explore schemas without risking your core data tables.

Runtime field masking also solves the all-or-nothing problem of static column policy tags. When a query fetches sensitive fields, masking rewrites matched fields in results right away. Emails, phone numbers, card numbers, and national IDs turn into safe placeholder text in flight. The agent gets valid query results to finish its code task without exposing private strings.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What cloud role should an OpenHands agent use for BigQuery?

Create a dedicated service account with dataset-level reader roles and job user permissions. Never assign project owner or editor roles to an automated coding agent.

How do I stop an OpenHands agent from running huge BigQuery scans?

Set a maximum bytes billed limit on your cloud project or user quota settings. Queries that exceed this scan limit will fail before they run and accrue charges.

Can BigQuery policy tags mask data for AI agents?

Native policy tags can apply basic masking rules if you configure data policies on columns. Still, runtime masking rewrites matched fields in results across queries without complex tag schemas.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.