How to Configure Mastra Bigquery Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a mastra bigquery approval flow by pausing agent steps before query execution. This pause waits for a human review before the agent sends the query to Google Cloud. Engineering teams often give AI agents broad cloud service accounts to speed up early testing. Those broad roles let an agent read sensitive tables or run expensive scans without a check. How a mastra bigquery approval workflow operates Mastra lets developers build AI agents that call external tools and run multi-step w

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 a mastra bigquery approval flow by pausing agent steps before query execution. This pause waits for a human review before the agent sends the query to Google Cloud. Engineering teams often give AI agents broad cloud service accounts to speed up early testing. Those broad roles let an agent read sensitive tables or run expensive scans without a check.

How a mastra bigquery approval workflow operates

Mastra lets developers build AI agents that call external tools and run multi-step workflows. When an agent needs data from Google Cloud, it prepares a query through a tool call. Without a review step, the agent runs that query right away using its cloud service account. To add a human check, developers use workflow suspension inside the agent orchestration logic.

When the agent reaches the data step, the workflow pauses and saves its current state. The app then sends the planned query text to a reviewer in Slack or a dashboard. A human engineer reads the query to check the target dataset and the cost impact. If the reviewer approves the request, the workflow resumes and runs the query in BigQuery. If the reviewer denies the request, the workflow stops and tells the agent to stop.

How cloud permissions pair with workflow checks

A workflow check works best when paired with tight Google Cloud IAM roles. Teams should never give an agent a project owner or editor role. Instead, admins create a custom service account with read access to specific datasets only. They also set query byte limits in the cloud console to stop runaway billing costs.

Even with narrow dataset roles, static keys in an agent app create a security risk. Anyone who gets the service account key can run queries outside the agent workflow. Teams must store these cloud credentials in a secret store and rotate them often. You should also log every tool call and reviewer choice for future security audits.

Approval Chains & Escalation + BigQuery IAM: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native setup solves and what keeps the session active

Combining workflow suspension with cloud IAM roles solves basic access control problems. Cloud IAM decides which service account can log in and which datasets it can see. App-level suspension gives humans a chance to check specific tool calls inside the Mastra app. Together, they stop unauthorized accounts and catch bad agent actions inside your code.

Still, this native setup leaves a major operational gap at the database layer. Cloud IAM checks who logs in, not what each individual SQL statement does in flight. App-level checks only work if every developer remembers to code the pause step in every tool. If a tool skips the pause step, the cloud warehouse still runs the query. Native cloud roles also fail to mask sensitive fields like emails or phone numbers in results. When a query runs, the agent receives raw card numbers or national IDs in the output.

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

Why do AI agents need approval before querying BigQuery?

AI agents write queries based on user prompts, which can lead to mistakes or prompt injection. An agent might scan huge tables and cause a massive cloud bill in seconds. A human check stops expensive scans and blocks access to sensitive company tables before execution.

Can Google Cloud IAM replace a query approval flow?

No, Google Cloud IAM only controls which datasets and tables a service account can access. It cannot inspect the text of an individual query or pause it for human review. You need a review flow to check specific SQL statements before they run.

How do you handle sensitive data in agent query results?

When an agent queries a table, raw fields return to the model context by default. To protect data, teams use data masking to rewrite matched fields in results. This step replaces emails, phone numbers, and card numbers before the agent reads the output.

The query runs. The emails stay hidden.