TL;DR
When you unleash a self-improving LLM agent on an A/B test or clinical trial, its iterative search for better data analyses inadvertently turns into automated $p$-hacking, more than doubling false-positive rates. This paper introduces Lock Before Reveal (LBR), a simple chronological rule that lets an agent continuously refine its causal analysis during an experiment using 100% of the data, sharpening statistical precision by up to 44% without ever corrupting the final confidence intervals.
What Problem Does This Paper Address?
Self-improving LLM agents thrive on a simple loop: propose a program, verify it against a reward, and build on what works. In standard machine learning, this is completely safe because you query a validation set freely to steer the search, and hold out a pristine test set for final evaluation.
In randomized experiments (like drug trials or product A/B tests), that luxury vanishes. You want to estimate an Average Treatment Effect (ATE), and to make that estimate precise—meaning narrower confidence intervals—analysts adjust for pre-treatment history (like a user's past 90 days of purchases) to cancel out background noise. Finding the best historical features across messy, multi-table relational databases is a great job for an LLM coding agent.
Here’s the catch: if an LLM tests multiple feature-engineering programs on experimental outcomes and picks the best one, the outcomes do double duty—steering the search and serving as the final statistical evidence. Randomization protects treatment assignment, not post-hoc cherry-picking. Left unchecked, an iterative LLM analyst hallucinates significance out of pure noise.
Methods
To let an agent learn from outcomes it will also be judged by, the authors combine standard doubly robust causal estimators (specifically Augmented Inverse Probability Weighting, or AIPW, paired with ridge regression) with two novel mechanisms:
- Lock Before Reveal (LBR): Instead of analyzing the experiment all at once, units are divided into $T$ sequential batches. Before batch $t$'s outcomes are revealed, the agent must lock its current pool of feature programs and fitted outcome models. Once revealed, the batch is scored once by that locked analysis—permanently entering the final ATE estimate—and only then are those outcomes used to evaluate new candidate programs for batch $t+1$. Because each batch's analysis is fixed before its random treatment assignments are seen, errors cancel out on average, keeping the overall estimate provably unbiased under any search policy.
- Causality-Driven Recursive Exploration: Rather than showing the LLM $p$-values, each new candidate program (written in a safe, typed domain-specific language that compiles to SQL) is judged by a marginal causal reward: how much adding it to the existing feature pool reduces outcome prediction error on the newly revealed batch. Programs with positive reward permanently join the pool. As the pool gets smarter, the bar rises, steering the LLM to hunt only for predictive signals the pool still lacks.
Datasets
The authors construct randomized experiments from 10 real-world regression tasks across RelBench and RelBench v2, spanning e-commerce, clinical trials, and social platforms (including Amazon, H&M, Stack Exchange, F1, Avito, RateBeer, Trial, and Event). Real user histories and future outcomes are preserved from the underlying relational databases, while randomized treatments with known ground-truth effects ($\tau = 1$ for precision tests, $\tau = 0$ for false-positive tests) are injected synthetically so statistical coverage can be verified exactly.
Key Insights and Ideas
- LLMs naturally $p$-hack when given outcome feedback: Even without malicious intent, letting an LLM refine covariate adjustments over 10 rounds while observing effect estimates inflates nominal 5% false positives to over 11%. LBR brings this right back down to baseline—not by changing the LLM's guardrails, which are notoriously brittle, but by enforcing strict temporal ordering.
- Data splitting can actually hurt you: The textbook remedy for adaptive search is holding out a slice of experimental data (say, 30%) just to select features, and estimating the treatment effect on the remaining 70%. Astonishingly, across every single LLM tested, separate-data search yielded wider confidence intervals than doing no covariate adjustment at all! Losing 30% of your sample size costs more statistical power than the learned features win back. LBR avoids this penalty entirely because every batch counts toward the final estimate.
- Causal rewards keep models lean: Without the marginal reward filtering candidates, the feature pool bloats to nearly twice the size (179 features vs. 95) and stops improving early.
Key Results
Evaluated across 12 LLMs from 8 model families (including GPT-5.6 Luna, Qwen3.5-9B, Gemma 4, DeepSeek-V4-Flash, MiniMax, GLM, MiMo, and Kimi):
- False-positive control: In 240 zero-effect experiments per model, naive same-data search hit 11.1% pooled false positives (9.6–12.5%). LBR brought this down to 6.8% (5.4–7.9%), matching a blind single-shot analysis (7.5%), with 2,000-seed checks confirming 94.9–95.0% nominal 95% coverage.
- Sharper precision: LBR narrowed confidence intervals by 13–17% on average compared to unadjusted estimation (and up to 44% on RateBeer and 32% on H&M), while beating separate-data search by 17–19% across all models.
- Beating human heuristics: Using only schema descriptions, the GPT-5.6 Luna agent outperformed CUPED (the industry-standard hand-crafted pre-period outcome adjustment) on 7 of 8 applicable tasks—and warm-starting LBR with CUPED shrank H&M interval widths even further, from 0.683 down to 0.593.
Limitations and Future Work
While the core mathematical guarantee is exact for unbiasedness, the confidence intervals rely on large-sample (asymptotic) martingale approximations, and are slightly conservative when treatment effects vary across individuals rather than staying constant. Additionally, the setup assumes known randomization probabilities bounded away from zero and one, availability of pre-experiment pilot data ($R_0$) to initialize the first batch's outcome models, and strict timestamps to prevent post-treatment data leakage. Future directions are not explicitly discussed in the main text of the paper.
Summary updated