EMNLP 2026
ReMCTS
ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generation
Code-writing agents try many programs in a search tree, and every failed branch teaches the others.
写代码的智能体在一棵搜索树上多路尝试,失败分支的经验会分享给其他分支,少走弯路。
Overview概览
Code written by large language models often looks right yet fails on edge cases and hidden tests, and common self-repair keeps patching a single attempt, so an early wrong algorithmic choice is hard to escape. Existing tree-search methods rank candidates with numeric rewards but do not share the textual diagnoses of failures across branches, and without tests they may mistake missing evidence for success. ReMCTS organizes candidate programs as a search tree, runs them in a sandbox for feedback, keeps each branch's debugging context, stores failure diagnoses in a shared memory that other branches retrieve, and tells failed checks apart from missing evidence. On HumanEval and MBPP it beats direct generation in 8 of 10 model–dataset pairs, and ablations show where the gains come from and where they stop.
大模型写的代码常常“看起来对”,却在边界条件或隐藏测试上出错;常见的自我修复只沿着一次尝试反复打补丁,一旦最初的算法思路错了就很难跳出来。已有的树搜索方法又主要依赖数值奖励,失败时的文字诊断没法分享给其他分支,在没有测试用例时还容易把“缺少证据”误当成“通过”。ReMCTS 把多个候选程序组织成一棵搜索树,在沙箱里执行获取反馈,保留每条分支的调试上下文,把失败经验存入全局记忆供其他分支检索复用,并区分“检查未通过”和“证据不足”。在 HumanEval 和 MBPP 上,ReMCTS 在 10 组模型—数据集组合中有 8 组优于直接生成,消融实验也厘清了收益的来源与边界。
Highlights要点
- Candidate programs grow into a search tree and run in a sandbox for feedback.把多个候选程序组织成搜索树,在沙箱里执行获取反馈。
- Failure diagnoses go into a shared memory that other branches retrieve; failed checks are told apart from missing evidence.失败诊断写进全局记忆,供其他分支检索复用,并区分“检查未通过”和“证据不足”。
- Beats direct generation in 8 of 10 model–dataset pairs on HumanEval and MBPP.在 HumanEval 和 MBPP 上,10 组模型—数据集组合中有 8 组优于直接生成。
Method方法

Citation引用
@inproceedings{huifei2026remcts,
title = {ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generation},
author = {Wang Huifei and Huang Xinying and Sun Yiheng and Yifan Yuan},
booktitle = {Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing},
year = {2026},
url = {https://arxiv.org/abs/2609.34717}
}