guide
guide8 min read

How Do You Check Data Integrity Before an AI Agent Acts on It?

A five-step pre-action trust gate that blocks agents from acting on stale, drifted or unsafe data

You check data integrity before an AI agent acts by putting a trust gate between the agent and the data: a set of fast, deterministic checks (freshness, volume, schema, validity and policy) that run immediately before each action and return allow, degrade or block. The idea of a continuous integrity check that runs before an agent acts is described in this data integrity write-up. The gate has to sit in the action path, not in a dashboard someone looks at tomorrow.

Key Takeaways

  • •A trust gate is a pre-action check, not a monitor: it runs in the agent's call path and can stop the action before it happens.
  • •Five checks cover most bad-data failures: freshness, volume, schema, validity and policy. Each returns a pass or fail the agent can act on.
  • •Agents should get a three-way verdict (allow, degrade, block) instead of a binary one, so a stale-but-safe table can still answer low-risk questions with a caveat.
  • •Reuse the tests you already have. dbt tests, Great Expectations suites and warehouse metadata can feed the gate without a new platform.
  • •Log every gate decision with the check results, so a blocked or allowed action can be explained later.

Why monitoring alone does not protect an agent

Most data quality tooling was built for humans. A check fails, an alert fires, an engineer looks at a dashboard and decides what to do. That loop assumes a person sits between the bad data and the decision. An agent removes that person. It reads a table, builds an answer or issues a write, and moves on in seconds, long before anyone opens the alert.

The failure mode is quiet. A late load leaves yesterday's numbers in a gold table, the agent reports them as current, and the summary reads fine. Nothing errors. This is the case behind questions like "Why did row counts drop 40% overnight?": the answer exists, but only after the agent has already used the data. Detection after the fact is table stakes. The gate moves the decision to before the action.

A gate also changes who is accountable. A monitor tells a team that something was wrong. A gate records that this action was checked against these conditions and received this verdict. That record is what you want when a stakeholder asks why the agent answered the way it did, and it is the difference between a guess and an audit.

Step 1: Declare what the agent is about to touch

A gate cannot check what it cannot see. Before any check runs, the agent's tool call has to resolve to a concrete set of assets: the tables, columns and views the action will read or write. If your agents talk to data through the Model Context Protocol, the tool call already names its inputs, so the gate can intercept the call, resolve those inputs to warehouse objects and attach the checks that apply to each.

Give each asset a small trust profile: its freshness SLA, expected row-count range, contract (columns and types), the tests that guard it and any sensitivity tags. A gold revenue table might require data under six hours old, a daily row count within a band, a stable customer_id type and no unmasked PII. A scratch table might require nothing. Not every asset deserves the same gate, and a uniform gate gets bypassed because it blocks too much.

Keep the profile in version control next to the model definitions. When the profile lives in a wiki, it drifts from the pipeline within a quarter. When it lives in the repo, a pull request that changes a column also changes its trust profile, and the reviewer sees both.

Step 2: Check freshness and volume

Freshness and volume are the cheapest checks and catch the most common failures. Freshness compares the newest timestamp or last-load time against the asset's SLA. Volume compares today's row count against a trailing window. Both run as a single lightweight query against metadata or an aggregate, so they add milliseconds, not seconds, to the agent's path.

Be explicit about what stale means for each action. A trend analysis can tolerate a day of lag. A refund decision cannot. Pass the action's tolerance into the gate so the same table can return allow for one caller and block for another. Warehouse history also helps when you need to compare against an earlier state: Snowflake documents a default Time Travel retention of 1 day, configurable up to 90 days on Enterprise Edition, which lets a gate compare current counts against a recent baseline without storing its own snapshots.

Volume checks should use ranges, not fixed thresholds. A weekend load is smaller than a weekday load, and a fixed floor will block every Sunday. Seasonality-aware baselines take a few weeks of history to settle, so start the gate in report-only mode and tune it before it is allowed to block.

Step 3: Check schema and contracts

A column that was renamed, retyped or dropped will not always raise an error. A join on a retyped key can silently return zero rows, and the agent will summarize that emptiness confidently. The gate should compare the live schema against the asset's contract and fail when a column the action depends on has changed in a way the contract does not allow.

This is where the question "Is the customer_id join safe after the migration?" belongs inside the gate rather than in a chat thread. The check resolves the columns the agent's query touches, compares their current types and nullability to the contract, and returns the specific column that broke. Our Schema Agent handles this kind of column-level drift detection and blast-radius mapping, and the gate simply asks it for a verdict on the columns in play.

Contracts and tests do different jobs, so use both. A contract guards the shape of the interface; tests guard the values inside it. A schema check that passes tells the agent the columns exist as expected, not that their contents are sane. That is the next step.

Step 4: Check validity and policy

Validity checks confirm that values are plausible: keys are unique, required fields are not null, categories fall within an allowed set, foreign keys resolve. You probably have these already. dbt ships four generic data tests out of the box: unique, not_null, accepted_values and relationships, and the open-source Great Expectations project provides a larger library of expectations. The gate should read the latest results of those tests rather than rerun them, and treat a failed test on a column the action uses as a failed check.

Policy checks answer a different question: is this agent allowed to see or change this data at all? Before the action, the gate verifies that the caller's role can access the columns involved, that PII columns are masked or excluded, and that a write has the approval it needs. This answers "Who has access to PII columns in analytics?" at the moment of use. Our Governance Agent maps those rules and our Quality Agent surfaces the test results, so the gate does not need its own copy of either.

Keep validity and policy results separate in the verdict. A validity failure means the data may be wrong. A policy failure means the action is not permitted, and no amount of clean data fixes that. Mixing them in one score hides which problem the on-call engineer has to solve.

Step 5: Return allow, degrade or block

The gate's output is a verdict the agent can act on. Allow means every check passed. Block means a critical check failed and the action must not run. Degrade is the useful middle: the data is stale or partially failing, so the agent may continue with a stated caveat, a narrower scope or a read-only result instead of a write. A binary gate pushes teams to loosen thresholds until nothing blocks, which defeats the purpose.

Tie the verdict to action risk. Reads for exploration can degrade on a freshness miss. Writes, customer-facing answers and anything that triggers money movement should block. This is the same reasoning behind deciding which agent actions need a human before they run: the stricter the consequence, the stronger the gate. A block should name the failed check, the asset and the timestamp, so the agent can report it plainly instead of improvising.

Every verdict should be written to an audit log with the check results attached. When an agent later gives a wrong answer, you can see whether the gate allowed it on stale data, degraded it with a caveat or never ran. Without that record, tuning the gate is guesswork.

Where Data Workers fits

You can build the gate from the pieces above, and many teams should. Data Workers packages the same pattern as coordinated agents. The Quality Agent supplies validity and anomaly results, the Observability Agent supplies freshness and lineage, the Schema Agent supplies drift and contract checks and the Governance Agent supplies access and PII policy. Because they share context, a blocked action arrives with the likely cause already traced instead of four separate alerts.

Every agent is an MCP server, so the gate runs where your engineers already work, in Claude Code, Cursor or any MCP-compatible client, with no new dashboard. The open-source edition is read-only by default, which means a trust gate that can block but cannot write is the safe place to start. Writes, approvals and audit trails come with Pro.

Whichever route you take, begin with report-only mode on your five most important gold tables. Watch the verdicts for two weeks, tune the thresholds and only then let the gate block. Teams that skip that step usually turn the gate off after the first false block.

Frequently Asked Questions

What is a pre-action trust gate?

A pre-action trust gate is a set of automated checks that run immediately before an AI agent reads, answers from or writes to data. It evaluates freshness, volume, schema, validity and policy for the specific assets involved and returns allow, degrade or block. It differs from monitoring because it sits in the agent's call path and can stop the action, rather than alerting a human afterward.

Will a trust gate slow my agents down?

Not noticeably if you design it well. Freshness, volume and schema checks read metadata or small aggregates and finish in milliseconds. The gate should read the latest stored results of your existing tests instead of rerunning them on every call. Reserve heavier checks for high-risk actions such as writes, and cache verdicts for a short window on read-only exploration.

Do I need new tooling, or can I reuse my dbt tests?

Reuse what you have. dbt tests, Great Expectations suites and warehouse metadata already encode most of the checks. The new work is the wiring: resolving an agent's tool call to assets, mapping each asset to its trust profile and returning a verdict in a form the agent understands. Start by reading existing test results and add dedicated checks only where gaps appear.