arXiv:2610.36952cs.SEOct 2026

Manuscript Offprint

arXiv:2610.36952

Does More Thinking Pay Off? Reasoning Cost and Correctness of LLMs in Code Generation and Bug Fixing

Andie Huang, Ying Pang, Qian Zhang, Yihang Cheng, Lin Ma

YONGHUI (ANDIE) HUANG*, Massey University, New Zealand

YING PANG*, Shandong University of Finance and Economics, China

QIAN ZHANG, University of Otago, New Zealand

YIHANG CHENG, University of Otago, New Zealand

LIN MA*, Alibaba Research Center for Complexity Sciences, Hangzhou Normal University, China

Many LLMs now emit an explicit reasoning trace before they write code, but benchmark results for code generation and bug fixing usually report correctness alone. It is therefore unclear how much the extra reasoning contributes relative to the tokens it consumes.

We examine this question with 866 Python tasks drawn from HumanEval Pro, MBPP Pro, and BugsInPy under five model settings. We look at the accuracy gain and token overhead of reasoning, the behaviors that appear inside reasoning traces, and whether a shortened trace still leads to a correct solution.

Turning reasoning on in Qwen3-32B over five runs improves mean pass@1 on HumanEval Pro from 71.1% to 76.5% and mean tests pass on BugsInPy from 3.5% to 7.9%. On MBPP Pro the improvement from 68.1% to 69.5% is not statistically significant, even though the model uses a median of over 2,000 thinking tokens per task. Across models, a longer median trace does not reliably mean higher accuracy. A qualitative analysis shows that traces mostly choose and check an implementation in code generation, while in bug fixing they mostly locate the fault and plan the repair.

We then truncate stored traces offline and ask Qwen3-32B with reasoning off to produce a solution from what remains. Retaining the first half of a trace yields no statistically significant drop in correctness. Stopping when the trace becomes repetitive seldom triggers, and stopping once solution code first appears benefits some models but harms others. Neither rule beats plain fixed truncation. These results suggest that more reasoning is not always better and that studies should report reasoning cost alongside correctness.

CCS Concepts: • Software and its engineering → Software creation and management; • Computing methodologies → Artificial intelligence.

Additional Key Words and Phrases: Large language models, software engineering, reasoning traces, reasoning efficiency, empirical study

1 Introduction

Large language models (LLMs) are now used across software engineering workflows. They appear in code generation and program repair [3, 24, 35]. Related work also studies their use in code review and test generation [19, 21]. LLMs with reasoning modes emit intermediate thinking content before the generated solution [13, 20, 28, 30]. This content adds thinking token overhead that standard correctness metrics do not capture. We call this content a reasoning trace. It is often delimited by <think>... </think> tags. In code tasks, the reasoning trace is where the model works toward a solution before it writes the final code. We measure this overhead with the Thinking Token Count (TTC), the number of tokens in a reasoning trace.

Reasoning traces matter for software engineering because code tasks require both correctness and efficiency. Models such as QwQ and Qwen3 can produce reasoning traces for code generation

∗^{*}Corresponding authors.

Authors' Contact Information: Yonghui (Andie) Huang, andie.huang@massey.ac.nz, Massey University, New Zealand; Ying Pang, ying.pang@sdufe.edu.cn, Shandong University of Finance and Economics, Jinan, China; Qian Zhang, zhaqi075@student.otago.ac.nz, University of Otago, New Zealand; Yihang Cheng, cheyi799@student.otago.ac.nz, University of Otago, New Zealand; Lin Ma, malin@hznu.edu.cn, Alibaba Research Center for Complexity Sciences, Hangzhou Normal University, Hangzhou, China.

Yonghui (Andie) Huang, Ying Pang, Qian Zhang, Yihang Cheng, and Lin Ma

Figure

A long hidden reasoning trace can yield a short final answer. The correctness of final answer alone does not expose token cost.

Fig. 1. An actual reasoning trace from Qwen3-32B on HumanEval Pro problem 20. The model generates 7,430 thinking tokens before producing a generated solution with 12 lines and 103 output tokens. The complete function already appears inside the reasoning trace, which then continues for another 211 tokens.

and bug fixing. Existing evaluations usually report only the outcome of the generated solution, such as pass@1 (the fraction of tasks solved by one generated solution) or whether a generated patch passes tests [24, 34, 35]. These metrics do not show what the reasoning trace contains, whether it changes correctness, or whether the entire reasoning trace is needed.

Figure 1 illustrates why solution correctness alone is insufficient for studying reasoning models on code tasks. The example is HumanEval Pro problem 20, which asks the model to write a function that returns the two closest numbers in a list. Qwen3-32B with reasoning enabled produces a correct generated solution with 12 lines and 103 output tokens, but it first generates 7,430 thinking tokens. The largest block is code revision, which takes 2,923 tokens. The reasoning trace also spends 1,541 tokens drafting code and 1,496 tokens selecting a method. Another 1,175 tokens go to understanding the task. Only 84 tokens are spent writing the solution, followed by 211 tokens of solution checking. This single example does not mean later reasoning is always unnecessary. It does show that correctness hides thinking token overhead and reasoning behavior.

Three gaps motivate this study. First, prior studies of chain of thought prompting and reasoning models mostly evaluate math and symbolic benchmarks or broad reasoning benchmarks [17, 28, 33]. Their results do not show whether reasoning traces improve executable code tasks enough to justify the additional thinking tokens. Second, studies of code generation and program repair usually evaluate the correctness of generated solutions [3, 24, 35]. They rarely separate the effect of explicit reasoning from differences in model choice or evaluation setup. Third, work on reasoning efficiency trains models to produce shorter reasoning, for example with rewards that reduce overthinking or with fine-tuning on compressed reasoning traces [13, 16, 36]. These methods assume that part of a reasoning trace is redundant. Analyses that measure how much reasoning is actually needed focus on math, commonsense, and multiple-choice questions [32]. For code tasks, a question that comes before designing such methods remains open. After a model has produced a long reasoning trace, can the final solution be generated from only an early prefix of that reasoning trace? This question matters because reasoning traces can be stored and used after generation. For example, a reasoning trace from LLM can be passed to a separate LLM model that writes the final answer [15], or compressed into shorter traces for training [16, 36]. We answer it on stored traces, so every truncation strategy is applied to the same reasoning and differences between strategies do not come from different generations.

We address these gaps with an empirical study of reasoning efficiency in code generation and bug fixing. The study covers code generation and bug fixing tasks from three benchmarks and reasoning traces from four models with reasoning enabled. For code generation, we use HumanEval Pro and MBPP Pro, which require a model to solve a base problem and reuse its solution in a more complex problem [38]. For bug fixing, we use BugsInPy, which contains real bugs from open-source Python projects [34]. We compare Qwen3-32B with reasoning enabled and disabled on the same tasks, and repeat this paired comparison over five generation runs to test how enabling reasoning affects correctness. We then annotate what the reasoning traces are used for across the two task families. Finally, we test whether a model can still generate a correct solution when it receives only an early prefix of a reasoning trace.

Our study asks three research questions.

RQ1 (Correctness and thinking token overhead). How does enabling reasoning affect task correctness and thinking token overhead? RQ2 (Reasoning behavior). What recurring behaviors appear in reasoning traces, and how do they differ between code generation and bug fixing? RQ3 (Reasoning prefix sufficiency). How much correctness is retained when a new answer is generated from a shorter reasoning prefix?

This paper makes three contributions.

(1) We compare Qwen3-32B with reasoning on and off across five generation runs. Reasoning produces higher mean accuracy on all three benchmarks. We test this gain with the exact McNemar test, which compares paired task outcomes within each run. The gain is significant in four of the five BugsInPy runs and in two of the five HumanEval Pro runs, but in none of the MBPP Pro runs. In our observations across the four models that generate reasoning traces, models with longer median reasoning traces do not consistently achieve higher accuracy. On HumanEval Pro, the accuracy of all four models ranges only from 76.0% to 77.1%, and on MBPP Pro, two of them score below Qwen3-32B with reasoning disabled.

(2) We derive a codebook with six behavior categories and test it on reasoning traces that were not used during development. In code generation, most labeled segments concern planning and checking an implementation. In bug fixing, they concern locating the fault and planning a repair.

(3) We provide an offline protocol for testing how much of a stored reasoning trace is needed to regenerate a correct solution, and we show that such experiments need a fair baseline. When Qwen3-32B with reasoning disabled writes a new answer from a shortened trace, this extra generation step can itself change correctness, so we compare it with the answer that the same model writes from the full trace. Against this baseline, the paired tests detect no significant correctness difference for any of the four reasoning models or three benchmarks when Fixed Truncation keeps only the first half of each stored reasoning trace. Neither Redundancy-based Stopping (RedStop), which stops when the reasoning text starts to repeat, nor the Necessary Reasoning Prefix (NRP) rule, which stops after solution code first appears, consistently improves on the fixed truncation.