Agentic Machine Learning: Pipelines That Check Every Stage, Tested on 400 Simulated Builds
In 400 simulated model builds, 300 with a planted fault, a holdout gate at the end approved every model, including a leaked one that scored 0.981 and then predicted 3.9% churn for customers who churned at 29.8%. Four checks placed where the faults enter stopped all 300 broken builds and none of the 100 clean ones. The Python, the results and where the checks fall short.

A gate at the end approved every broken model
I ran 400 simulated model builds through an agentic machine learning pipeline and planted one of three common faults in 300 of them. A holdout gate at the end, the usual floor of 0.70 AUC, approved all 400. It gave its best marks to the worst model: the build with target leakage averaged a holdout AUC of 0.981 on data where the best possible model scores about 0.81. In production that model predicted a 3.9% churn rate for customers who churned at 29.8%.
Four checks, each placed at the stage where one of the faults enters, stopped all 300 broken builds and flagged none of the 100 clean ones. None of the checks is new. What changes when an agent runs the pipeline is how many builds go through it and how few of them a person reads line by line, so the checks have to live in the pipeline, run on every build, and sit where the agent cannot rewrite them.
This piece is part of a Monday series on agentic systems at the level of practice. The code below runs in about four minutes on two CPU cores, and every number in the text comes from it or from the sources at the end.
Why agentic machine learning needs checks at every stage
Agents now do real machine learning engineering. In October 2024, OpenAI's MLE-bench put agents through 75 Kaggle competitions; the best setup, o1-preview with the AIDE scaffold, reached at least a bronze medal level in 16.9% of them. That is a long way from reliable, and it is also a long way from nothing. Teams are already handing agents the steps in between: joining tables, building features, splitting data, fitting candidates and writing the serving code.
The faults that matter most in those steps are old ones. Sayash Kapoor and Arvind Narayanan's survey of leakage in machine-learning-based science, updated in May 2024, lists 41 papers from 30 fields that found errors, collectively affecting 648 papers, and sorts leakage into 8 types. The first two on their list are a training and test set without a clean separation, and a model that uses features which are not legitimate. People made those mistakes in published research before agents wrote any of it.
An agent changes the arithmetic. Say each of four stages has a 5% chance of a fault in a given build:
About 18.5% of builds would carry a fault somewhere. A person reviewing ten models a quarter might catch most of them by reading the code. An agent producing ten builds a day needs the review written down as tests. The agent reliability analysis works through the same compounding for a 20-step task.
The experiment: 400 builds with a known answer
The data is a simulated churn problem where the true probability of churn is known for every customer. Six fields (tenure, monthly spend in dollars, support tickets, logins, discount and plan changes) drive a logistic model with fixed effects, and the churn rate comes out near 30%. Because the true probabilities are known, so is the ceiling: the best AUC any model could reach on each holdout, which averages 0.813 to 0.820 across the four kinds of run.
Each build draws 5,000 customers, splits 4,000 for training and 1,000 for the holdout, fits a random forest, and scores a fresh 5,000 customers as production. One hundred builds are clean. The other 300 carry one fault each:
- Target leakage. The training table includes a field written after a customer cancels, so it nearly encodes the label. At prediction time the field is empty.
- Train and holdout overlap. An oversampling step runs before the split and 500 training rows end up in the 1,000-row holdout.
- A units change at serving. The model trains on monthly spend in dollars. The production feed sends cents.
Each of these is a fault an agent can make while every individual step looks reasonable: the leaked field sits in the same warehouse table, oversampling is a standard fix for imbalance, and a feed in cents passes every type check.
The review policies are the end gate (approve when holdout AUC is at least 0.70) and four stage checks:
- Split. Hash every row; no row may appear in both training and holdout.
- Features. No single column may predict the label with an AUC above 0.90 on its own.
- Holdout. At least 0.70, and no more than 0.05 above the last approved model scored on the same rows. Here the last approved model is a logistic regression on the six original fields.
- Serving. For every field, the production median must sit within half an interquartile range of the training median.
"""Agentic machine learning: does a pipeline that checks every stage catch
what a single holdout gate at the end lets through?
Simulated churn data with a known truth. Each run builds a model the way an
agent might, sometimes with one planted fault, then applies two review
policies: one holdout gate at the end, or a check at every stage.
Runs in about four minutes on two CPU cores (scikit-learn 1.9, NumPy 2.5).
"""
import hashlib
import json
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
FEATURES = ["tenure_months", "monthly_spend_usd", "support_tickets",
"logins_30d", "discount_pct", "plan_changes"]
BETA = np.array([-0.90, 0.60, 0.70, -0.65, 0.30, 0.25]) # true effects, per SD
INTERCEPT = -1.2
MIN_AUC = 0.70 # floor: the end-of-pipeline gate
MAX_JUMP = 0.05 # most a new model may beat the last approved one by
def simulate(n, rng):
"""Customers with a known churn probability. Spend is in dollars."""
z = rng.normal(size=(n, len(FEATURES)))
p = 1 / (1 + np.exp(-(INTERCEPT + z @ BETA)))
y = rng.binomial(1, p)
X = z.copy()
X[:, 1] = 60 + 25 * z[:, 1] # monthly spend, USD
return np.round(X, 3), y, p
def build(fault, rng):
"""One pipeline run. Returns everything a reviewer could look at."""
X, y, p = simulate(5000, rng)
X_prod, y_prod, _ = simulate(5000, rng)
if fault == "leakage":
# a field written after the customer cancels; empty at prediction time
X = np.column_stack([X, np.round(y + rng.normal(0, 0.35, len(y)), 3)])
X_prod = np.column_stack([X_prod, np.zeros(len(y_prod))])
idx = rng.permutation(len(y))
tr, te = idx[:4000], idx[4000:]
X_tr, y_tr, X_te, y_te = X[tr], y[tr], X[te], y[te]
honest = np.arange(len(te)) # holdout rows that are truly new
te_new = te # their row numbers in X
if fault == "overlap":
# an oversampling step run before the split copies 500 training rows
# into the holdout
k = 500
copy = rng.choice(len(y_tr), k, replace=False)
X_te = np.vstack([X_te[k:], X_tr[copy]])
y_te = np.concatenate([y_te[k:], y_tr[copy]])
honest = np.arange(len(te) - k)
te_new = te[k:]
if fault == "units":
X_prod = X_prod.copy()
X_prod[:, 1] *= 100 # serving feed sends cents
model = RandomForestClassifier(n_estimators=150, min_samples_leaf=5,
n_jobs=-1, random_state=int(rng.integers(1e9)))
model.fit(X_tr, y_tr)
# the last approved model: a logistic regression on the six original fields
prior = LogisticRegression(max_iter=1000).fit(X_tr[:, :6], y_tr)
prior_auc = roc_auc_score(y_te[honest],
prior.predict_proba(X_te[honest, :6])[:, 1])
return dict(
X_tr=X_tr, y_tr=y_tr, X_te=X_te, X_prod=X_prod,
holdout_auc=roc_auc_score(y_te, model.predict_proba(X_te)[:, 1]),
prod_auc=roc_auc_score(y_prod, model.predict_proba(X_prod)[:, 1]),
prod_pred_rate=float(model.predict_proba(X_prod)[:, 1].mean()),
prod_true_rate=float(y_prod.mean()),
prior_auc=prior_auc,
ceiling=roc_auc_score(y[te_new], p[te_new]), # best any model could do
)
def failed_checks(r):
"""Every stage check this run fails, in pipeline order."""
failed = []
# 1. split: no row may appear in both training and holdout
digest = lambda A: {hashlib.md5(row.tobytes()).hexdigest() for row in A}
if digest(r["X_tr"]) & digest(r["X_te"]):
failed.append("split")
# 2. features: no single column may predict the label almost perfectly
for j in range(r["X_tr"].shape[1]):
a = roc_auc_score(r["y_tr"], r["X_tr"][:, j])
if max(a, 1 - a) > 0.90:
failed.append("features")
break
# 3. holdout: above the floor, and not suspiciously above the last
# approved model scored on the same rows
if not MIN_AUC <= r["holdout_auc"] <= r["prior_auc"] + MAX_JUMP:
failed.append("holdout")
# 4. serving: production inputs must look like training inputs
med_tr = np.median(r["X_tr"], axis=0)
iqr_tr = np.subtract(*np.percentile(r["X_tr"], [75, 25], axis=0))
shift = np.abs(np.median(r["X_prod"], axis=0) - med_tr) / iqr_tr
if np.any(shift > 0.5):
failed.append("serving")
return failed
if __name__ == "__main__":
rng = np.random.default_rng(20261130)
runs = 100
results = {}
for fault in ["none", "leakage", "overlap", "units"]:
rows = [build(fault, rng) for _ in range(runs)]
fails = [failed_checks(r) for r in rows]
mean = lambda key: float(np.mean([r[key] for r in rows]))
results[fault] = {
"end_gate_passed": sum(r["holdout_auc"] >= MIN_AUC for r in rows),
"stage_checks_stopped": sum(bool(f) for f in fails),
"first_stop": {s: sum(1 for f in fails if f and f[0] == s)
for s in ["split", "features", "holdout", "serving"]},
"any_trip": {s: sum(s in f for f in fails)
for s in ["split", "features", "holdout", "serving"]},
"holdout_auc": mean("holdout_auc"),
"prod_auc": mean("prod_auc"),
"prod_auc_min": float(min(r["prod_auc"] for r in rows)),
"prod_pred_rate": mean("prod_pred_rate"),
"prod_true_rate": mean("prod_true_rate"),
"prior_auc": mean("prior_auc"),
"ceiling": mean("ceiling"),
"max_holdout_minus_prior": float(max(
r["holdout_auc"] - r["prior_auc"] for r in rows)),
}
print(fault, json.dumps(results[fault], default=lambda v: round(v, 3)))
with open("stage_checks_results.json", "w") as f:
json.dump(results, f, indent=1)
What the holdout gate saw, and what production got
The end gate approved all 100 builds of every kind. Actual churn in production was 29.8% for every kind of build.
| Build | Stage checks stopped | First check to stop it | Holdout AUC | Production AUC | Predicted churn |
|---|---|---|---|---|---|
| Clean | 0 of 100 | none | 0.795 | 0.795 | 30.0% |
| Target leakage | 100 of 100 | features | 0.981 | 0.759 | 3.9% |
| Train and holdout overlap | 100 of 100 | split | 0.895 | 0.795 | 29.9% |
| Units change at serving | 100 of 100 | serving | 0.796 | 0.765 | 48.1% |
AUC and predicted churn are means over 100 builds.
Each fault fooled the end gate in its own way.
The leaked model looked best. A field that nearly encodes the label pushes the holdout AUC to 0.981, far above the 0.81 that any honest model could reach, and a gate with only a floor reads that as excellent news. In production the field is empty, the model reads the blank as a customer who did not cancel, and its predicted churn rate falls to 3.9%. Ranking still works a little (production AUC 0.759, lowest single run 0.737) because the six real fields carry some signal, so a dashboard that only tracks AUC would show a mild decline rather than a broken model.
The overlap builds are a different kind of wrong. The model in production is as good as the clean one, 0.795, but the holdout says 0.895. Every decision made from that number is off by 0.10 AUC, starting with which candidate wins and how much lift to promise. Copies of training rows in the holdout are easy for a random forest, which has seen them.
The units fault is invisible to any holdout. Training and holdout both come from the same table in dollars, so the holdout AUC is 0.796, the same as the clean builds. Only production sees cents. Every customer now looks like the biggest spender in the training data, and predicted churn jumps to 48.1% against an actual 29.8%. The model expects about 1.6 times as many cancellations as actually happen, so a retention budget sized from its scores is too big, and spent on the wrong customers.
The checks also overlap where it helps. The leakage builds tripped two checks each (features and the holdout jump), the overlap builds tripped two (split and the holdout jump), and the units builds tripped one: serving. A fault that only shows up at serving time has exactly one place to be caught, and it is the last stop before customers.
Four checks for an agentic machine learning pipeline
The checks in the script are deliberately plain, and each maps to a habit a careful data scientist already has.
Split check. Hash rows (or entity IDs, for repeated customers) and fail on any match across training and holdout. For time series, add a check that every holdout timestamp is later than every training timestamp. This is a few lines of code and it stopped all 100 overlap builds.
Feature check. Score every column on its own against the label. A single field with an AUC above 0.90 is almost always either the label in disguise or a field recorded after the outcome. The stronger version is a data contract: each feature carries the time it becomes available, and the pipeline rejects any feature that becomes available after the prediction time. The single-column screen is the fallback when that metadata does not exist yet.
Holdout check with a ceiling. A floor alone cannot tell a strong model from a leaked one. Comparing against the last approved model on the same rows gives the gate an upper bound: here the clean forests never beat the logistic baseline at all (the largest gap was 0.00004 below it), while every leaked and overlapped build beat it by more than the 0.05 allowance. In real data the true ceiling is unknown, so the last approved model, or a simple baseline fitted in the same run, stands in for it. A jump well above that baseline should open an investigation, not a launch.
Serving check. Compare the production inputs with the training inputs before the scores go anywhere: medians and ranges per field, share of nulls, and categories that never appeared in training. Here the cents feed moved the spend median by about 176 interquartile ranges: a median of 60 becomes 6,000, against an interquartile range of about 34. A real drift check, a population stability index or a two-sample test per field, catches subtler shifts than this one.
Google's ML Test Score rubric (Breck and coauthors, 2017) lists 28 specific tests and monitoring needs for production machine learning. The four above are a small subset. They are the four that map onto the faults planted here, and they are the ones that cost least to automate.
Where the checks sit relative to the agent
Two practice rules matter more than any particular threshold.
The agent does not own its checks. If an agent can edit the test that judges its work, a failing build can become a passing one with a one-line change to a threshold. The checks live in a separate, versioned place, changes to them need a person's approval, and the agent sees the result of a check but cannot rewrite it. The same idea runs through a self-improving system that needs a judge it cannot edit and through benchmarks that agents can game.
A failed check stops the build. Warnings that an agent can note and pass over are reports, and the point of a stage check is that the broken model never reaches the next stage. A person decides what happens next: fix the feature, rerun the split, or accept the risk in writing.
The Agentic ML demo walks a holiday discount model from a brief to a monitored deployment with these kinds of gates in place: data checks, a holdout gate, a person's sign-off and a canary. The demo shows the stages and the gates; this article tests why they need to be there.
What this means for teams in Kansas City
Most data science teams in Kansas City, in health care, financial services, engineering and retail, will not hand an agent a whole pipeline this year. They will hand it pieces: a feature build, a backfill, a retraining job. Each piece is a stage, and the question to ask before turning an agent loose on it is which check would stop it if it went wrong. If the answer is "the holdout AUC at the end", the simulation says that answer catches none of the three faults here. More on the region's data science work is in the data science in Kansas City research topic.
Where this breaks
Each check here was written knowing which fault it had to catch, so "300 of 300" is a statement about these faults, not about every fault an agent can make. A fault no one thought to test for, a subtle label definition change or a slow drift in one region, passes all four checks. The real value of stage checks is that each one closes a known door permanently; finding the next door still takes people reading code and results.
The thresholds are choices. The 0.90 single-feature screen would flag a legitimate field that really is that predictive, which happens in fraud and credit work, and the half interquartile range serving rule is loose enough to miss a 20% rise in monthly spend (12 dollars on a 60 dollar median, about 0.36 of an interquartile range). With zero false alarms in 100 clean builds, the rule of three puts a rough 95% upper bound on the false alarm rate at 3%, which is a small sample for a pipeline that runs every day.
The simulated world is friendly. The true model is logistic, so the logistic baseline sits near the ceiling and makes the holdout check easy to set; on messy data the baseline is weaker and the allowed jump has to be judged. The forest stands in for whatever model an agent picks. And production here is a single clean draw from the same population, with none of the seasonality, delayed labels or feedback loops that real churn models live with.
About the author
Brian Curry leads Vector1, a research, applied science and machine learning lab in Kansas City that runs on a proprietary agentic operating system he designed. The lab works across data science, machine learning, AI and agentic systems, causal modeling, and system design and architecture. Over the past decade, he has directed data science, machine learning, applied and agentic AI, advanced analytics, and data architecture initiatives across major enterprises from $4 billion to $125 billion. Vector1's work includes Gedanken Galaxy (patent pending) and the open-source Python libraries PyCausalSim, for causal discovery and simulation, and Papilon, a complex systems framework for Bayesian marketing mix modeling. He previously founded KC AI Lab, expanding the regional practitioner network to over 1,500 members. His open-source frameworks, benchmarks, and research are available at vector1.ai.
More on agent-run model building, verification gates and monitoring is in the Agentic Machine Learning research area.
Sources
- Jun Shern Chan, Neil Chowdhury, Oliver Jaffe and coauthors, MLE-bench: Evaluating Machine Learning Agents on Machine Learning Engineering, arXiv, October 2024
- Sayash Kapoor and Arvind Narayanan, Leakage and the Reproducibility Crisis in ML-based Science, Princeton University, Patterns 2023, survey table updated May 2024
- Eric Breck, Shanqing Cai, Eric Nielsen, Michael Salib and D. Sculley, The ML Test Score: A Rubric for ML Production Readiness and Technical Debt Reduction, Proceedings of IEEE Big Data, 2017

