NExT: Teaching Large Language Models to Reason about Code Execution
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
A fundamental skill among human developers is the ability to understand and reason about program execution. As an example, a programmer can mentally simulate code execution in natural language to debug and repair code (aka. rubber duck debugging). However, large language models (LLMs) of code are typically trained on the surface textual form of programs, thus may lack a semantic understanding of how programs execute at run-time. To address this issue, we propose NExT, a method to teach LLMs to inspect the execution traces of programs (variable states of executed lines) and reason about their run-time behavior through chain-of-thought (CoT) rationales. Specifically, NExT uses self-training to bootstrap a synthetic training set of execution-aware rationales that lead to correct task solutions (e.g., fixed programs) without laborious manual annotation. Experiments on program repair tasks based on MBPP and HumanEval demonstrate that NExT improves the fix rate of a PaLM 2 model, by 26.1% and 14.3% absolute, respectively, with significantly improved rationale quality as verified by automated metrics and human raters. Our model can also generalize to scenarios where program traces are absent at test-time.
Key facts. Cited by 60 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 65 of its 87 references that are in the map. First posted on arXiv 23 Apr 2024.
Builds on
65 of 87 references.
Closest ancestors · 3
Same direction, newest first
- 2023Teaching Large Language Models to Self-Debug11 Apr
- 2023LEVER: Learning to Verify Language-to-Code Generation with Execution16 Feb
- 2022Reasoning Like Program Executors27 Jan
Other references · 62
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Let's Verify Step by Stepcited by 3,598
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2022Scaling Instruction-Finetuned Language Modelscited by 2,997
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2024Mixtral of Expertscited by 1,785
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2023PaLM 2 Technical Reportcited by 1,154
38 more
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2022STaR: Bootstrapping Reasoning With Reasoningcited by 895
- 2023Math-Shepherd: Verify and Reinforce LLMs Step-by-step without Human Annotationscited by 895
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2022Solving math word problems with process- and outcome-based feedbackcited by 871
- 2023StarCoder: may the source be with you!cited by 790
- 2023The Flan Collection: Designing Data and Methods for Effective Instruction Tuningcited by 734
- 2014Neural Turing Machinescited by 630
- 2023Textbooks Are All You Needcited by 561
- 2023Orca: Progressive Learning from Complex Explanation Traces of GPT-4cited by 369
- 2019Explain Yourself! Leveraging Language Models for Commonsense Reasoningcited by 367
- 2022Teaching Small Language Models to Reasoncited by 279
- 2023Specializing Smaller Language Models towards Multi-Step Reasoningcited by 249
- 2017Thinking Fast and Slow with Deep Learning and Tree Searchcited by 245
- 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
- 2019SPoC: Search-based Pseudocode to Codecited by 176
- 2020Unsupervised Commonsense Question Answering with Self-Talkcited by 161
- 2023Orca 2: Teaching Small Language Models How to Reasoncited by 157
- 2018SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repaircited by 144
- 2022Practical Program Repair in the Era of Large Pre-trained Language Modelscited by 133
- 2023An Analysis of the Automatic Bug Fixing Performance of ChatGPTcited by 108
- 2014Learning to Executecited by 105
- 2022Automating Code Review Activities by Large-Scale Pre-trainingcited by 98
- 2023The Programmer's Assistant: Conversational Interaction with a Large Language Model for Software Developmentcited by 95
- 2022Natural Language to Code Generation in Interactive Data Science Notebookscited by 86
- 2023Impact of Code Language Models on Automated Program Repaircited by 85
- 2022Less Training, More Repairing Please: Revisiting Automated Program Repair via Zero-shot Learningcited by 76
- 2023ReCEval: Evaluating Reasoning Chains via Correctness and Informativenesscited by 76
- 2022Automated Repair of Programs from Large Language Modelscited by 71
- 2018Memory Augmented Policy Optimization for Program Synthesis and Semantic Parsingcited by 57
- 2018Robust Text-to-SQL Generation with Execution-Guided Decodingcited by 51
- 2023Training Chain-of-Thought via Latent-Variable Inferencecited by 46
- 2023Explainable Automated Debugging via Large Language Model-driven Scientific Debuggingcited by 40
- 2020Synthesize, Execute and Debug: Learning to Repair for Neural Program Synthesiscited by 39
- 2022Learning Math Reasoning from Self-Sampled Correct and Partially-Correct Solutionscited by 38
- 2020Learning to Execute Programs with Instruction Pointer Attention Graph Neural Networkscited by 35
- 2021Latent Execution for Neural Program Synthesiscited by 35
- 2016Programming with a Differentiable Forth Interpretercited by 33
50 most cited of 62 All 62 (JSON)
Built on by
Citing papers per year: 2024: 11; 2025: 30; 2026: 19.
60 papers.
Sort:
By area:
- 2024Training Language Models to Self-Correct via Reinforcement Learningcited by 405
- 2025A Survey on Test-Time Scaling in Large Language Models: What, How, Where, and How Well?cited by 215
- 2024Lingma SWE-GPT: An Open Development-Process-Centric Language Model for Automated Software Improvementcited by 57
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debuggingcited by 46
- 2026Code as Agent Harnesscited by 40
- 2025Teaching Language Models to Critique via Reinforcement Learningcited by 38
- 2025Mitigating Overthinking in Large Reasoning Models via Manifold Steeringcited by 32
- 2026Group-Evolving Agents: Open-Ended Self-Improvement via Experience Sharingcited by 32
- 2024Surveying the Effects of Quality, Diversity, and Complexity in Synthetic Data From Large Language Modelscited by 31
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
- 2025Multi-Turn Code Generation Through Single-Step Rewardscited by 27
38 more
- 2024PyBench: Evaluating LLM Agent on various real-world coding taskscited by 24
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checkingcited by 23
- 2025cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax Treecited by 17
- 2025Learning to Generate Unit Tests for Automated Debuggingcited by 16
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoningcited by 14
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 12
- 2025What I cannot execute, I do not understand: Training and Evaluating LLMs on Program Execution Tracescited by 11
- 2024LLMs as Continuous Learners: Improving the Reproduction of Defective Code in Software Issuescited by 10
- 2024Coffee-Gym: An Environment for Evaluating and Improving Natural Language Feedback on Erroneous Codecited by 9
- 2024CodeNav: Beyond tool-use to using real-world codebases with LLM agentscited by 8
- 2025CoCoNUT: Structural Code Understanding does not fall out of a treecited by 7
- 2025HoarePrompt: Structural Reasoning About Program Correctness in Natural Languagecited by 7
- 2025Agent That Debugs: Dynamic State-Guided Vulnerability Repaircited by 7
- 2024CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinementcited by 6
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Modelscited by 6
- 2025The KoLMogorov Test: Compression by Code Generationcited by 5
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Executioncited by 5
- 2025LLMs Lean on Priors, Not Programming Language Semanticscited by 5
- 2026ExecVerify: White-Box RL with Verifiable Stepwise Rewards for Code Execution Reasoningcited by 5
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
- 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learningcited by 4
- 2025Towards Verified Code Reasoning by LLMscited by 4
- 2026Aletheia: What Makes RLVR For Code Verifiers Tick?cited by 4
- 2025Gradient-Based Program Repair: Fixing Bugs in Continuous Program Spacescited by 3
- 2025Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Modelscited by 3
- 2025Think Socially via Cognitive Reasoningcited by 2
- 2026Towards AGI A Pragmatic Approach Towards Self Evolving Agentcited by 2
- 2024Morescient GAI for Software Engineering (Extended Version)cited by 1
- 2025Investigating Execution-Aware Language Models for Code Optimizationcited by 1
- 2025Replacing thinking with tool usage enables reasoning in small language modelscited by 1
- 2026Rethinking Code Similarity for Automated Algorithm Design with LLMscited by 1
- 2026Towards a Neural Debugger for Pythoncited by 1
- 2026Agentic MIP Research: Accelerated Constraint Handler Generationcited by 1
- 2026StepCodeReasoner: Aligning Code Reasoning with Stepwise Execution Traces via Reinforcement Learningcited by 1
- 2025Why Stop at One Error? Benchmarking LLMs as Data Science Code Debuggers for Multi-Hop and Multi-Bug Errorscited by 0
- 2025Generating Verifiable Chain of Thoughts from Exection-Tracescited by 0
50 most cited of 60 All 60 (JSON)
- 2026From Verification Failures to Reusable Guidance for Coding Agents30 Sep 2026
- 2026Improving Large Language Models for Code through Runtime Program-State Reasoning28 Sep 2026
- 2026On the Lexical Superstition of Large Language Models for Code Comprehension: Re-evaluation on Code of Low Lexical Quality22 Sep 2026
- 2026Predicting Program Exit Code with LLMs and Programming Language Semantics1 Sep 2026
- 2026MicroAgent: Context-Augmented Multi-Agent Framework for Automatic Microservice Decomposition29 Jun 2026
- 2026AgentCompile: An LLM-Guided Compiler for Direct CUDA Inference4 Jun 2026
- 2026Code as Agent Harness18 May 2026
- 2026MemRepair: Hierarchical Memory for Agentic Repository-Level Vulnerability Repair17 May 2026
- 2026StepCodeReasoner: Aligning Code Reasoning with Stepwise Execution Traces via Reinforcement Learning12 May 2026
- 2026Agentic MIP Research: Accelerated Constraint Handler Generation9 May 2026
- 2026Teaching LLMs Program Semantics via Symbolic Execution Traces7 May 2026
- 2026An Empirical Analysis of Static Analysis Methods for Detection and Mitigation of Code Library Hallucinations9 Apr 2026
38 more
- 2026SemRep: Generative Code Representation Learning with Code Transformations13 Mar 2026
- 2026ExecVerify: White-Box RL with Verifiable Stepwise Rewards for Code Execution Reasoning11 Mar 2026
- 2026Towards a Neural Debugger for Python10 Mar 2026
- 2026Rethinking Code Similarity for Automated Algorithm Design with LLMs3 Mar 2026
- 2026Group-Evolving Agents: Open-Ended Self-Improvement via Experience Sharing4 Feb 2026
- 2026Aletheia: What Makes RLVR For Code Verifiers Tick?17 Jan 2026
- 2026Towards AGI A Pragmatic Approach Towards Self Evolving Agent15 Jan 2026
- 2025Generating Verifiable Chain of Thoughts from Exection-Traces28 Nov 2025
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025LLMs Lean on Priors, Not Programming Language Semantics3 Oct 2025
- 2025Towards Verified Code Reasoning by LLMs30 Sep 2025
- 2025Think Socially via Cognitive Reasoning26 Sep 2025
- 2025Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Models15 Sep 2025
- 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learning23 Jul 2025
- 2025Replacing thinking with tool usage enables reasoning in small language models7 Jul 2025
- 2025cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax Tree18 Jun 2025
- 2025Mitigating Overthinking in Large Reasoning Models via Manifold Steering28 May 2025
- 2025Gradient-Based Program Repair: Fixing Bugs in Continuous Program Spaces23 May 2025
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoning19 Apr 2025
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMs16 Apr 2025
- 2025Agent That Debugs: Dynamic State-Guided Vulnerability Repair10 Apr 2025
- 2025A Survey on Test-Time Scaling in Large Language Models: What, How, Where, and How Well?31 Mar 2025
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis29 Mar 2025
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Execution28 Mar 2025
- 2025Why Stop at One Error? Benchmarking LLMs as Data Science Code Debuggers for Multi-Hop and Multi-Bug Errors28 Mar 2025
- 2025HoarePrompt: Structural Reasoning About Program Correctness in Natural Language25 Mar 2025
- 2025The KoLMogorov Test: Compression by Code Generation18 Mar 2025
- 2025Investigating Execution-Aware Language Models for Code Optimization11 Mar 2025
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testing10 Mar 2025
- 2025Multi-Turn Code Generation Through Single-Step Rewards27 Feb 2025
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMs26 Feb 2025
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checking18 Feb 2025
- 2025What I cannot execute, I do not understand: Training and Evaluating LLMs on Program Execution Traces10 Feb 2025
- 2025Teaching Language Models to Critique via Reinforcement Learning5 Feb 2025
- 2025Learning to Generate Unit Tests for Automated Debugging3 Feb 2025
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Models30 Jan 2025
- 2025CoCoNUT: Structural Code Understanding does not fall out of a tree27 Jan 2025
- 2024Surveying the Effects of Quality, Diversity, and Complexity in Synthetic Data From Large Language Models4 Dec 2024
50 newest of 60 All 60 (JSON)
- 2024Training Language Models to Self-Correct via Reinforcement Learningcited by 405
- 2025A Survey on Test-Time Scaling in Large Language Models: What, How, Where, and How Well?cited by 215
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2025Teaching Language Models to Critique via Reinforcement Learningcited by 38
- 2025Mitigating Overthinking in Large Reasoning Models via Manifold Steeringcited by 32
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checkingcited by 23
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoningcited by 14
- 2025HoarePrompt: Structural Reasoning About Program Correctness in Natural Languagecited by 7
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Modelscited by 6
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Executioncited by 5
12 most cited of 21 All 21 (JSON)
- 2026Improving Large Language Models for Code through Runtime Program-State Reasoning28 Sep 2026
- 2026ExecVerify: White-Box RL with Verifiable Stepwise Rewards for Code Execution Reasoning11 Mar 2026
- 2026Rethinking Code Similarity for Automated Algorithm Design with LLMs3 Mar 2026
- 2025Generating Verifiable Chain of Thoughts from Exection-Traces28 Nov 2025
- 2025LLMs Lean on Priors, Not Programming Language Semantics3 Oct 2025
- 2025Towards Verified Code Reasoning by LLMs30 Sep 2025
- 2025Think Socially via Cognitive Reasoning26 Sep 2025
- 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learning23 Jul 2025
- 2025Replacing thinking with tool usage enables reasoning in small language models7 Jul 2025
- 2025Mitigating Overthinking in Large Reasoning Models via Manifold Steering28 May 2025
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoning19 Apr 2025
- 2025A Survey on Test-Time Scaling in Large Language Models: What, How, Where, and How Well?31 Mar 2025
12 newest of 21 All 21 (JSON)
- 2024Lingma SWE-GPT: An Open Development-Process-Centric Language Model for Automated Software Improvementcited by 57
- 2026Code as Agent Harnesscited by 40
- 2024PyBench: Evaluating LLM Agent on various real-world coding taskscited by 24
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2024CodeNav: Beyond tool-use to using real-world codebases with LLM agentscited by 8
- 2025Agent That Debugs: Dynamic State-Guided Vulnerability Repaircited by 7
- 2026Towards AGI A Pragmatic Approach Towards Self Evolving Agentcited by 2
- 2026Agentic MIP Research: Accelerated Constraint Handler Generationcited by 1
- 2026MemRepair: Hierarchical Memory for Agentic Repository-Level Vulnerability Repaircited by 0
- 2026MicroAgent: Context-Augmented Multi-Agent Framework for Automatic Microservice Decompositioncited by 0
- 2026From Verification Failures to Reusable Guidance for Coding Agentscited by 0
- 2026From Verification Failures to Reusable Guidance for Coding Agents30 Sep 2026
- 2026MicroAgent: Context-Augmented Multi-Agent Framework for Automatic Microservice Decomposition29 Jun 2026
- 2026Code as Agent Harness18 May 2026
- 2026MemRepair: Hierarchical Memory for Agentic Repository-Level Vulnerability Repair17 May 2026
- 2026Agentic MIP Research: Accelerated Constraint Handler Generation9 May 2026
- 2026Towards AGI A Pragmatic Approach Towards Self Evolving Agent15 Jan 2026
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025Agent That Debugs: Dynamic State-Guided Vulnerability Repair10 Apr 2025
- 2024Lingma SWE-GPT: An Open Development-Process-Centric Language Model for Automated Software Improvement1 Nov 2024
- 2024PyBench: Evaluating LLM Agent on various real-world coding tasks23 Jul 2024
- 2024CodeNav: Beyond tool-use to using real-world codebases with LLM agents18 Jun 2024
- 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debuggingcited by 46
- 2025Learning to Generate Unit Tests for Automated Debuggingcited by 16
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 12
- 2025What I cannot execute, I do not understand: Training and Evaluating LLMs on Program Execution Tracescited by 11
- 2024LLMs as Continuous Learners: Improving the Reproduction of Defective Code in Software Issuescited by 10
- 2025CoCoNUT: Structural Code Understanding does not fall out of a treecited by 7
- 2024CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinementcited by 6
- 2025The KoLMogorov Test: Compression by Code Generationcited by 5
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
- 2026Aletheia: What Makes RLVR For Code Verifiers Tick?cited by 4
- 2025Gradient-Based Program Repair: Fixing Bugs in Continuous Program Spacescited by 3
- 2025Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Modelscited by 3
12 most cited of 21 All 21 (JSON)
- 2026On the Lexical Superstition of Large Language Models for Code Comprehension: Re-evaluation on Code of Low Lexical Quality22 Sep 2026
- 2026Predicting Program Exit Code with LLMs and Programming Language Semantics1 Sep 2026
- 2026Teaching LLMs Program Semantics via Symbolic Execution Traces7 May 2026
- 2026An Empirical Analysis of Static Analysis Methods for Detection and Mitigation of Code Library Hallucinations9 Apr 2026
- 2026SemRep: Generative Code Representation Learning with Code Transformations13 Mar 2026
- 2026Towards a Neural Debugger for Python10 Mar 2026
- 2026Aletheia: What Makes RLVR For Code Verifiers Tick?17 Jan 2026
- 2025Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Models15 Sep 2025
- 2025Gradient-Based Program Repair: Fixing Bugs in Continuous Program Spaces23 May 2025
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMs16 Apr 2025
- 2025Why Stop at One Error? Benchmarking LLMs as Data Science Code Debuggers for Multi-Hop and Multi-Bug Errors28 Mar 2025
- 2025The KoLMogorov Test: Compression by Code Generation18 Mar 2025
12 newest of 21 All 21 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2024SemCoder: Training Code Language Models with Comprehensive Semantics Reasoning
- 2025Chain of Execution Supervision Promotes General Reasoning in Large Language Models
- 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation
- 2026Can LLMs Reason About Runtime Behavior? A Repository-Level Dynamic Benchmark
- 2025Code Execution as Grounded Supervision for LLM Reasoning
- 2025Towards Effectively Leveraging Execution Traces for Program Repair with Code LLMs
- 2026CodeEval: A pedagogical approach for targeted evaluation of code-trained Large Language Models
- 2025PACIFIC: a framework for generating benchmarks to check Precise Automatically Checked Instruction Following In Code