An AI Agent Built for Data Checks: Catching Bugs and Making Mistakes

November 23, 2026
AIAgentic AIData QualityGreat ExpectationsData EngineeringCI/CD

Most data quality tutorials start with a table you already understand. This one starts with an unfamiliar inventory feed and a small agent pipeline that profiles it, proposes Great Expectations checks, and turns failures into a prioritized fix list, showing where the agent helped and where human judgment was still needed.

An AI Agent Built for Data Checks: Catching Bugs and Making Mistakes

Most data quality tutorials start with a table you already understand. You know the columns, the business rules, and what “healthy” looks like. But what about tables that are unfamiliar, have no documentation, and no indicator of what to fix first?

With AI, we can now ingest data faster than ever, but finding issues in it is the tricky part. To put AI to the test, I built a small pipeline to handle a first pass: profile a table, propose checks, run them with Great Expectations (GX Core 1.x), and turn failures into a prioritized report instead of a raw JSON file.

This pipeline was then tested against a realistic business scenario: a used-car marketplace’s vehicle inventory feed. The goal was to see where the agent helped, where its assumptions fell short, and where human judgment was still needed.

Explore the full code on GitHub.

The setup: one feed, three problem areas

Picture AutoLot, a fictional online used-car marketplace. Dealers upload inventory daily, and that feed directly powers three parts of the business:

  • The search and filter experience buyers use to find vehicles.
  • The pricing algorithm that flags underpriced or overpriced listings.
  • The dealer performance dashboard.

When the feed is quietly broken, all three can be wrong at once. Often times, nobody notices these errors until a salesman asks why a car isn’t showing up or a buyer spots a listing priced at “-$800.”

To recreate the problem, I built a synthetic vehicle listings table with 500 rows and carefully seeded five issues that can occur in inventory feeds:

  • Missing dealer attribution: A few null dealer_id values, representing a sync job that dropped attribution.
  • A duplicate vehicle: One duplicate Vehicle Identification Number (VIN), representing the same physical car being ingested again under a new listing ID.
  • A negative price: One listing associated with a negative price, representing a currency or discount calculation bug.
  • An invalid condition: One condition value of "wrecked", outside the marketplace’s accepted taxonomy of new, used, certified pre-owned, and salvage.
  • A future listing date: One future-dated listed_date, representing a time zone bug in the ingestion job.

The workflow was straightforward: profile, propose, review, run, and triage. Building a minimal version made it easier to examine what each step contributed, and where an automated assumption could become a bad business rule.

Agent 1: Useful Proposals, Imperfect Assumptions

The profiling agent scans each column for nulls, cardinality, and range, then applies simple heuristics to draft an ExpectationSuite.

Nothing goes live automatically. Each proposed check comes with a rationale so a person can review it before it becomes part of the validation process.

The logic includes rules like these:

col_looks_like_id = any(col_lower.endswith(suffix) for suffix in ID_SUFFIXES)

is_text = any(t in col_type_upper for t in ("TEXT", "VARCHAR", "CHAR", "STRING"))
is_enum_like = is_text and 2 <= cardinality <= ENUM_CARDINALITY_THRESHOLD

is_numeric = any(
    t in col_type_upper
    for t in ("INT", "REAL", "FLOAT", "NUMERIC", "DECIMAL", "DOUBLE")
) and not col_looks_like_id

For example, a column named order_id or customer_id looks like an identifier, so the heuristic considers whether it should be unique. That is a useful starting point, but the column name alone doesn’t explain its role in the business setting.

Agent 1 successfully caught the duplicated VIN. Rather than silently adding a uniqueness check that would immediately fail, it surfaced the issue for review:

# REVIEW: `vin` looks like a PK but already has duplicates
# (1 duplicate row detected). Fix upstream before adding a uniqueness expectation.
# suite.add_expectation(
#     ExpectColumnValuesToBeUnique(**{"column": "vin"})
# )

The useful part was the visibility: the draft called attention to an existing problem and made the proposed check explicit.

Where Agent 1 stumbled

The same “_id means unique” assumption also raised a concern about dealer_id, which contained hundreds of repeated values.

But a dealer with dozens of cars in inventory is exactly what the marketplace should expect. Those repeated IDs reflect the business model.

The review output highlighted the ambiguity:

# REVIEW: `dealer_id` ends in '_id' but is probably a foreign key
# (cardinality=160 vs 500 rows). Foreign keys should NOT have a uniqueness
# expectation - remove this if dealers can list multiple vehicles.
# suite.add_expectation(
#     ExpectColumnValuesToBeUnique(**{"column": "dealer_id"})
# )

A naming convention can suggest that a field is an identifier. It cannot tell you whether that field is a primary key or a foreign key—or whether repeated values are expected.

Another agent error: learning the wrong valid values.

For condition, Agent 1 found five distinct values and proposed all five as valid. That included "wrecked", the value I had deliberately injected as invalid.

# REVIEW: `condition` has low cardinality (5 distinct values).
# Proposed set: ['certified pre-owned', 'new', 'salvage', 'used', 'wrecked']
# WARNING: this set is derived from observed data - it may include invalid values
# already present. Verify against the authoritative list before enabling.

The proposed check accurately reflected the data it had seen. It did not reflect the marketplace’s actual rules. That distinction matters. Profiling can tell you what exists in a data table. Deciding what belongs there requires business context, such as an approved taxonomy or an understanding of how dealers and vehicles relate.

Both examples reinforced why the output needed to remain a reviewable draft.

Running the checks

Once a human has reviewed and refined the draft, the validation follows the standard GX Core 1.x structure: a Data Source, a Data Asset, a Batch Definition, a Suite, a Validation Definition, and a Checkpoint.

Against the seeded data, four of seven checks failed, catching:

  • The duplicate VIN.
  • The null dealer IDs.
  • The negative price.
  • The invalid condition.

The run_checks.py script exits with code 1 when any check fails, allowing the validation to act as a gate in continuous integration (CI). That makes the reviewed checks part of the delivery workflow, where failures can get attention before they become harder-to-trace downstream problems.

Agent 2: turning failure responses into a to-do list

A check can correctly identify a problem and still fail to prompt action. If someone has to dig through raw JSON to understand what happened, even a useful alert can sit unread.

The second agent addresses that gap by turning validation results into a prioritized report.

Its severity rules rank VIN and price issues above condition and date fields. Each failure type also receives a specific next step:

  • Duplicate VIN: Check the dealer’s feed or sync job for repeated ingestion.
  • Missing dealer attribution: Review the ingestion mapping step.
  • Unexpected condition value: Confirm the accepted values with the merchandising team.

With ANTHROPIC_API_KEY set, the workflow also asks Claude to write a Slack-ready summary.

The report gives someone a practical place to start: what failed, which issues deserve attention first, and where to investigate. The next steps guide triage without establishing the root cause on their own.

Wiring it into CI

With the connection string configured through a secret and the workflow pointed at the target data source, the checks can run on every push and pull request.

That brings the process into an existing engineering routine. The reviewed expectations define what should pass, the validation flags failures, and the triage report helps the team decide what to investigate next.

What “agentic” buys you here

The goal of this experiment was to reduce the work between receiving an unfamiliar table and having useful checks ready for review.

The first agent produces a draft. The second organizes failures into a ranked fix list. A human still decides whether the proposed rules make sense for the business.

This implementation also makes the mechanics visible: the profiling and prioritization rely on explicit heuristics, with an optional Claude-generated summary. That distinction helps explain both its usefulness and its limitations.

A valid foreign key can look like a duplicate problem. An invalid value can look normal simply because it already exists in the data. Without the right context, an automated proposal can carry a flawed assumption straight into a check.

That is why human-in-the-loop matters. The agent gets the initial work onto the page so someone with business knowledge can evaluate it, correct it, and put it to use.

For teams working through unfamiliar data, there is a practical opportunity in creating these pipelines. The agent handles the initial work of examining the data and suggesting quality checks. The team can then review those suggestions and make fixes that correctly reflect how the business works.

Explore the project

The full code, including both agents, is available on GitHub.