As AI agents increasingly contribute to code development and maintenance, there is still limited empirical evidence on the quality and risk characteristics of their changes in real-world projects, particularly for refactoring-oriented contributions. It remains unclear how agent-authored refactoring edits affect maintainability, code quality, and security once merged into GitHub repositories. To address this gap, we conduct an empirical study of Python refactoring pull requests (PRs) from the AIDev dataset. We analyze agentic refactoring PRs using PyQu, an ML-based quality assessment tool for Python, to quantify changes across five quality attributes, and we complement PyQu with domain-independent static analysis (Pylint and Bandit) to measure code quality and security issues before and after each change. Our results show that, on average, agentic commits improve a quality attribute in 22.5% of the studied changes, with usability improving most frequently (36.5%). At the same time, 24.17% of modified files introduce new Pylint issues predominantly convention level violations such as long lines-while 4.7% introduce new Bandit findings. From the observed diffs, we derive a taxonomy of 24 recurring change operations and map them to the lint and security findings they most commonly affect. Despite these mixed outcomes, developer acceptance is high: 73.5% of the analyzed PRs are merged, including cases that introduce new lint or security findings, often alongside the removal of existing issues. Overall, these findings highlight both the promise and current limitations of agentic refactoring, and motivate stronger tool-in-the-loop quality and security gating for AI-driven development workflows.
翻译:随着AI智能体越来越多地参与代码开发与维护,目前仍缺乏关于其变更在真实世界项目中质量和风险特征的经验证据,特别是针对重构导向的贡献。当智能体编写的重构编辑被合并到GitHub仓库后,这些变更如何影响可维护性、代码质量与安全性仍不明确。为填补这一空白,我们基于AIDev数据集对Python重构拉取请求(PRs)开展了实证研究。我们利用基于机器学习的Python质量评估工具PyQu分析智能体重构PRs,量化五个质量属性的变化,并配合领域无关的静态分析工具(Pylint和Bandit)补充PyQu分析结果,以度量每次变更前后的代码质量与安全问题。研究结果显示,在被分析变更中,平均有22.5%的智能体提交改进了某一质量属性,其中可用性改进最为频繁(36.5%)。同时,24.17%的修改文件引入了新的Pylint问题,主要为约定级别违规(如过长代码行),而4.7%的文件引入了新的Bandit检测结果。通过观察差异内容,我们推导出包含24种重复变更操作的分类体系,并将其映射至最常受其影响的lint与安全检测结果。尽管存在这些混合结果,开发者接受度仍然较高:73.5%的被分析PRs被合并,包括那些引入新lint或安全问题的案例——这些案例通常也同时移除了既有问题。总体而言,这些发现既揭示了智能体重构的潜力,也暴露了其当前局限性,并驱动在AI驱动开发流程中部署更强的工具协同质量与安全管控机制。