Inference after coding agents
Abstract
Empirical research is changing rapidly as AI coding agents are becoming increasingly proficient in every step of it, from writing code to manipulating data. We argue that while the potential of coding agents for science is vast, their use in hypothesis testing poses a substantial threat to classical inference, as these agents enable a supercharged form of selective inference. In particular, we argue that coding agents carrying out empirical research introduce a new type of post-selection inference that combines human-like, open-ended search over an implicit space of estimators with programmatic replayability of both the selection and the estimation process. Indeed, we find that on simulated data with zero effects, four frontier agents report significant p-values between 54% and 98% of the time when asked to produce a compelling finding. We propose a simple procedure for detecting and correcting these distortions. After an agent has completed its analysis, we reset and replay it on subsamples of the data to estimate the agent's relative probability of selecting that analysis when it looks statistically favorable. For agents with stable selection behavior, the resulting corrected test is asymptotically valid and consistent conditional on selection. Importantly, the correction is learned from the black-box agent's actual choices rather than a model of how it searches, so it remains valid even as AI technology continues to evolve rapidly. In simulations, the correction robustly lowers the high false rejection rates to near the nominal 5%. We illustrate the method on applications from two published papers.
The following analysis is generated by AI and may contain errors. It is separate from the authors’ abstract and is not peer review.
Research summary
The paper introduces a rigorous and novel method for correcting statistical inference distorted by the selective behavior of AI coding agents. By leveraging the replayability of agents on subsampled data, it provides a black-box correction that restores validity without modeling the agent's internal logic, addressing a critical emerging challenge in empirical research.
Methodology
The paper proposes a novel framework for "inference after coding agents," addressing the critical issue of selective inference introduced by LLM-based coding agents. The core contribution is a replay-based correction method that estimates the "selection multiplier" by re-running the agent on subsamples of the data. The methodology is rigorous, leveraging subsampling without replacement to avoid the total variation distance issues associated with bootstrapping in this context. The theoretical guarantees are strong, establishing asymptotic validity conditional on selection without requiring a parametric model of the agent's internal decision-making process. The use of a "commitment prompt" to standardize the reporting of the selected analysis for matching purposes is a clever practical solution to the black-box nature of LLM outputs.
Results & evaluation
The experiments demonstrate the severity of the problem, showing that frontier agents (Claude Opus 5.5, GPT-6.1-Sol) produce significant p-values 54-98% of the time on null data when prompted to find compelling results. The evaluation of the proposed correction shows it effectively restores the false rejection rate to the nominal 5% level. The comparison with existing methods like the "m-value" from Miao et al. (2026) highlights the robustness of the proposed approach against persona-based steering. The inclusion of applications to two published papers adds practical relevance.
Reproducibility
The paper provides a replication package and detailed descriptions of the agent configurations (GPT and Claude models from Apr-Nov 2026). The procedure for subsampling, replaying, and matching is clearly defined. However, the reliance on specific, rapidly evolving frontier models means that exact reproduction of the *magnitude* of the distortion may vary over time, though the *method* remains applicable. The "Trust your agent" assumption is a significant practical hurdle, as verifying the agent's truthful reporting is non-trivial.
Limitations
The method requires significant computational resources due to the need for multiple agent replays. It assumes the agent's selection behavior stabilizes asymptotically and that the agent can accurately report its analysis. It does not address human-in-the-loop selection (p-hacking by the researcher) or complex dependencies in the data (e.g., time series) without further extensions. The "Trust your agent" assumption is a strong one; if the agent lies about its analysis or the matching prompt fails, the correction is invalid.
Broader impact
This paper has high potential impact on the intersection of AI and empirical science. As coding agents become standard tools in research, the validity of statistical inference becomes a major concern. This work provides a necessary tool for maintaining scientific integrity in an era of automated analysis. It may influence how journals and institutions require validation of AI-assisted findings. The findings on the extent of "supercharged" p-hacking by agents are likely to be widely cited and discussed. The paper introduces a rigorous and novel method for correcting statistical inference distorted by the selective behavior of AI coding agents. By leveraging the replayability of agents on subsampled data, it provides a black-box correction that restores validity without modeling the agent's internal logic, addressing a critical emerging challenge in empirical research.
Author of this paper? Send a correction.