RethinkMCTS: Refining Erroneous Thoughts in Monte Carlo Tree Search for Code Generation
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
Tree search methods have demonstrated impressive performance in code generation. Previous methods combine tree search with reflection that summarizes past mistakes to achieve iterative improvement. However, these methods face significant challenges. First, they search directly within the code language space, neglecting the underlying reasoning process critical for effective code generation. Second, reflection-based approaches merely accumulate historical errors in memory without providing correct reasoning pathways, making it difficult for subsequent search iterations to identify optimal solutions, resulting in decreased search quality. In this work, we propose RethinkMCTS, a framework that systematically explores and refines the reasoning process for code generation. Specifically, we employ MCTS to search for thoughts before code generation and integrate MCTS with a refinement mechanism called rethink, which incorporates fine-grained code execution feedback to refine erroneous thoughts during the search. It ensures the search path aligns with better reasoning, improving overall search quality. Through extensive experiments, we demonstrate that RethinkMCTS outperforms previous search-based and feedback-enhanced code generation baselines.
Key facts. Cited by 25 papers in the map (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 32 of its 51 references that are in the map. First posted on arXiv 15 Sep 2024.
Builds on
32 of 51 references.
Closest ancestors · 2
Same direction, newest first
- 2023Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models6 Oct
- 2023Reasoning with Language Model is Planning with World Model24 May
Other references · 30
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,155
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Large Language Models Cannot Self-Correct Reasoning Yetcited by 965
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2023StarCoder: may the source be with you!cited by 790
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2017Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithmcited by 723
18 more
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2023Alphazero-like Tree-Search can Guide Large Language Model Decoding and Trainingcited by 291
- 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 278
- 2023Using an LLM to Help With Code Understandingcited by 222
- 2023Planning with Large Language Models for Code Generationcited by 179
- 2019SPoC: Search-based Pseudocode to Codecited by 176
- 2024Self-Organized Agents: A LLM Multi-Agent Framework toward Ultra Large-Scale Code Generation and Optimizationcited by 84
- 2024Planning In Natural Language Improves LLM Search For Code Generationcited by 79
- 2023CodeScore: Evaluating Code Generation by Learning Code Executioncited by 66
- 2023Large Language Models are In-Context Semantic Reasoners rather than Symbolic Reasonerscited by 63
- 2024Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedbackcited by 45
- 2024LLM-A*: Large Language Model Enhanced Incremental Heuristic Search on Path Planningcited by 44
- 2024Make Every Move Count: LLM-based High-Quality RTL Code Generation Using MCTScited by 42
- 2024Uncertainty of Thoughts: Uncertainty-Aware Planning Enhances Information Seeking in Large Language Modelscited by 37
- 2024AST-T5: Structure-Aware Pretraining for Code Generation and Understandingcited by 32
- 2024LiteSearch: Efficacious Tree Search for LLMcited by 30
- 2024Enhancing LLM-Based Coding Tools through Native Integration of IDE-Derived Static Contextcited by 10
- 2024Let the Code LLM Edit Itself When You Edit the Codecited by 8
Built on by
Citing papers per year: 2024: 4; 2025: 15; 2026: 6.
25 papers.
Sort:
By area:
- 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Modelscited by 381
- 2025From System 1 to System 2: A Survey of Reasoning Large Language Modelscited by 319
- 2025S*: Test Time Scaling for Code Generationcited by 95
- 2025ReSo: A Reward-driven Self-organizing LLM-based Multi-Agent System for Reasoning Taskscited by 30
- 2024Agentic Information Retrievalcited by 19
- 2025Generative AI Act II: Test Time Scaling Drives Cognition Engineeringcited by 14
- 2025Navigating the Alpha Jungle: An LLM-Powered MCTS Framework for Formulaic Factor Miningcited by 13
- 2026MMSkills: Towards Multimodal Skills for General Visual Agentscited by 13
- 2024SRA-MCTS: Self-driven Reasoning Augmentation with Monte Carlo Tree Search for Code Generationcited by 9
- 2025Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimizationcited by 9
- 2025From Large to Small: Transferring CUDA Optimization Expertise via Reasoning Graphcited by 9
- 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinementcited by 6
13 more
- 2025LLM-First Search: Self-Guided Exploration of the Solution Spacecited by 5
- 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debuggingcited by 4
- 2024Seed-CTS: Unleashing the Power of Tree Search for Superior Performance in Competitive Coding Taskscited by 3
- 2024Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinementcited by 3
- 2025Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generationcited by 2
- 2025Monte Carlo Tree Diffusion with Multiple Experts for Protein Designcited by 2
- 2026Policy of Thoughts: Scaling Test-Time Training for LLM Reasoning via Online Policy Evolutioncited by 2
- 2026Plan-MCTS: Plan Exploration for Action Exploitation in Web Navigationcited by 2
- 2025Towards Stepwise Domain Knowledge-Driven Reasoning Optimization and Reflection Improvementcited by 0
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Educationcited by 0
- 2026LogitsCoder: Towards Efficient Chain-of-Thought Path Search via Logits Preference Decoding for Code Generationcited by 0
- 2026ROSUM-MCTS: Monte Carlo Tree Search-Inspired HDL Code Summarization with Structural Rewardscited by 0
- 2026ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generationcited by 0
- 2026ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generation28 Sep 2026
- 2026ROSUM-MCTS: Monte Carlo Tree Search-Inspired HDL Code Summarization with Structural Rewards6 Jun 2026
- 2026MMSkills: Towards Multimodal Skills for General Visual Agents13 May 2026
- 2026Plan-MCTS: Plan Exploration for Action Exploitation in Web Navigation15 Feb 2026
- 2026LogitsCoder: Towards Efficient Chain-of-Thought Path Search via Logits Preference Decoding for Code Generation15 Feb 2026
- 2026Policy of Thoughts: Scaling Test-Time Training for LLM Reasoning via Online Policy Evolution28 Jan 2026
- 2025From Large to Small: Transferring CUDA Optimization Expertise via Reasoning Graph22 Oct 2025
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Education13 Oct 2025
- 2025Monte Carlo Tree Diffusion with Multiple Experts for Protein Design19 Sep 2025
- 2025Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimization8 Aug 2025
- 2025LLM-First Search: Self-Guided Exploration of the Solution Space5 Jun 2025
- 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debugging21 May 2025
13 more
- 2025Navigating the Alpha Jungle: An LLM-Powered MCTS Framework for Formulaic Factor Mining16 May 2025
- 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinement29 Apr 2025
- 2025Generative AI Act II: Test Time Scaling Drives Cognition Engineering18 Apr 2025
- 2025Towards Stepwise Domain Knowledge-Driven Reasoning Optimization and Reflection Improvement12 Apr 2025
- 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Models12 Mar 2025
- 2025ReSo: A Reward-driven Self-organizing LLM-based Multi-Agent System for Reasoning Tasks4 Mar 2025
- 2025From System 1 to System 2: A Survey of Reasoning Large Language Models24 Feb 2025
- 2025S*: Test Time Scaling for Code Generation20 Feb 2025
- 2025Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generation18 Feb 2025
- 2024Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinement30 Dec 2024
- 2024Seed-CTS: Unleashing the Power of Tree Search for Superior Performance in Competitive Coding Tasks17 Dec 2024
- 2024SRA-MCTS: Self-driven Reasoning Augmentation with Monte Carlo Tree Search for Code Generation17 Nov 2024
- 2024Agentic Information Retrieval13 Oct 2024
- 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Modelscited by 381
- 2025From System 1 to System 2: A Survey of Reasoning Large Language Modelscited by 319
- 2025S*: Test Time Scaling for Code Generationcited by 95
- 2025ReSo: A Reward-driven Self-organizing LLM-based Multi-Agent System for Reasoning Taskscited by 30
- 2025Generative AI Act II: Test Time Scaling Drives Cognition Engineeringcited by 14
- 2024SRA-MCTS: Self-driven Reasoning Augmentation with Monte Carlo Tree Search for Code Generationcited by 9
- 2025From Large to Small: Transferring CUDA Optimization Expertise via Reasoning Graphcited by 9
- 2025LLM-First Search: Self-Guided Exploration of the Solution Spacecited by 5
- 2024Seed-CTS: Unleashing the Power of Tree Search for Superior Performance in Competitive Coding Taskscited by 3
- 2024Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinementcited by 3
- 2025Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generationcited by 2
- 2026Policy of Thoughts: Scaling Test-Time Training for LLM Reasoning via Online Policy Evolutioncited by 2
12 most cited of 14 All 14 (JSON)
- 2026LogitsCoder: Towards Efficient Chain-of-Thought Path Search via Logits Preference Decoding for Code Generation15 Feb 2026
- 2026Policy of Thoughts: Scaling Test-Time Training for LLM Reasoning via Online Policy Evolution28 Jan 2026
- 2025From Large to Small: Transferring CUDA Optimization Expertise via Reasoning Graph22 Oct 2025
- 2025LLM-First Search: Self-Guided Exploration of the Solution Space5 Jun 2025
- 2025Generative AI Act II: Test Time Scaling Drives Cognition Engineering18 Apr 2025
- 2025Towards Stepwise Domain Knowledge-Driven Reasoning Optimization and Reflection Improvement12 Apr 2025
- 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Models12 Mar 2025
- 2025ReSo: A Reward-driven Self-organizing LLM-based Multi-Agent System for Reasoning Tasks4 Mar 2025
- 2025From System 1 to System 2: A Survey of Reasoning Large Language Models24 Feb 2025
- 2025S*: Test Time Scaling for Code Generation20 Feb 2025
- 2025Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generation18 Feb 2025
- 2024Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinement30 Dec 2024
12 newest of 14 All 14 (JSON)
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Education13 Oct 2025
- 2024Agentic Information Retrieval13 Oct 2024
- 2025Navigating the Alpha Jungle: An LLM-Powered MCTS Framework for Formulaic Factor Miningcited by 13
- 2026MMSkills: Towards Multimodal Skills for General Visual Agentscited by 13
- 2025Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimizationcited by 9
- 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debuggingcited by 4
- 2025Monte Carlo Tree Diffusion with Multiple Experts for Protein Designcited by 2
- 2026Plan-MCTS: Plan Exploration for Action Exploitation in Web Navigationcited by 2
- 2026ROSUM-MCTS: Monte Carlo Tree Search-Inspired HDL Code Summarization with Structural Rewardscited by 0
- 2026ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generationcited by 0
- 2026ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generation28 Sep 2026
- 2026ROSUM-MCTS: Monte Carlo Tree Search-Inspired HDL Code Summarization with Structural Rewards6 Jun 2026
- 2026MMSkills: Towards Multimodal Skills for General Visual Agents13 May 2026
- 2026Plan-MCTS: Plan Exploration for Action Exploitation in Web Navigation15 Feb 2026
- 2025Monte Carlo Tree Diffusion with Multiple Experts for Protein Design19 Sep 2025
- 2025Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimization8 Aug 2025
- 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debugging21 May 2025
- 2025Navigating the Alpha Jungle: An LLM-Powered MCTS Framework for Formulaic Factor Mining16 May 2025
Similar, not cited
Close in wording, no citation either way
- 2025RPM-MCTS: Knowledge-Retrieval as Process Reward Model with Monte Carlo Tree Search for Code Generation
- 2025MCTS-Judge: Test-Time Scaling in LLM-as-a-Judge for Code Correctness Evaluation
- 2025Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
- 2024THOUGHTSCULPT: Reasoning with Intermediate Revision and Search
- 2026GraphAHA: Graph-Based Adaptive Search with Heterogeneous Actions for Test-Time Code Generation
- 2025SELF-REDRAFT: Eliciting Intrinsic Exploration-Exploitation Balance in Test-Time Scaling for Code Generation
- 2026ExeCRE: Execution-Consistency Guided Reliability Estimation for Self-Correcting Code Generation
- 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval