Paper commentary
Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models
Explicit reasoning can exhaust the output budget before code appears
- Problem Explicit reasoning can use up the whole output budget, so a code model never returns an answer. Until now, nobody had measured how often this happens across code benchmarks.
- Method The authors measure overflow in seven open-weight reasoning models under a fixed 32k-token budget. They also test prompt steering and budgeted transitions that end reasoning early.
- Results Budgeted transitions lifted CodeReason-7B pass@1 by almost 20 percentage points over its standard reasoning run.

Fig. 1 .Results for RQ1 Overflow Dynamics.Distribution of reasoning-token usage under the standard reasoning-enabled setting. Each violin shows the percentage of the 32k output budget consumed by the explicit reasoning trace for a given model and benchmark. The dashed red line marks the full output budget, and the percentage above each violin reports thereasoning-trace overflowrate.
Original paper · CC BY 4.0 · Lukas Twist, Helen Yannakoudakis, Jie M. Zhang · Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models · Original paper figure · Extracted the figure area from page 4 of the original PDF.Where the output budget runs out
For harder problems, both demands can grow together, so the budget can run out before any code appears. The authors call this reasoning-trace overflow, and it differs from ordinary verbosity because no answer is produced at all. Prior budget-control work mostly targets mathematical and general reasoning, so code generation gets less attention.
The authors write the output as y, split into a reasoning trace y_r and an answer y_a, where either segment may be empty. Given a budget B, overflow occurs when |y| = B, |y_r| = B and |y_a| = 0. The condition requires generation to stop at the budget while still inside the reasoning trace. The definition is strict on purpose, so a long reasoning trace that still reaches an answer doesn't count as overflow.
The study uses this idea as its central lens, asking first when models approach or exhaust the budget. Finally, they test whether lightweight inference-time controls can reduce overflow while preserving accuracy.
How runs are split and flagged
Every model runs with greedy decoding at temperature 0.0 and top p 1.0, so each task yields one solution scored by pass@1. Smaller operational budgets would only expose extra generations that had not yet finished reasoning. The same budget applies to every model, so the reported overflow rates are measured under one shared constraint.
Each output is split into a reasoning trace and an answer using the standard think delimiters, through ThinkPack. The authors don't try to extract code from an unfinished trace, because it never reached the answer protocol. Token counts use each model's own tokenizer.
The loop detector takes the final 64-character suffix of a trace and finds its nearest earlier occurrence. The distance between those two positions serves as a candidate repetition period. The detector then traces this periodic pattern backwards until it breaks. These conservative thresholds keep short or incidental repetition from being counted as a loop.
Where overflow concentrates and how it relates to loops
Overflow is rare on EvalPlus, where most models spend only a small fraction of the budget on reasoning. OpenReason-7B is the exception, overflowing on 27.7% of EvalPlus tasks, while the larger Qwen models almost never overflow. Across the Qwen family, overflow falls sharply as size grows from Qwen3-8B to Qwen3-32B.
On LiveCodeBench and CodeContests, several models spend a large share of the budget on reasoning, and overflow becomes substantial. BigCodeBench overflows less than these two, which the authors read as a sign that problem difficulty drives overflow more than library use. CRUX-Input is different, because Llama-R1-8B, OpenReason-7B and CodeReason-7B overflow often even though their answers are short.
Loops account for most complete overflow, since 94% of overflowed generations contain a detected loop. That rate sits between 85% and 100% for most models, and OLMo3-7B is lower at 62%. Long reasoning is not only looping, though, because 99% of generations that reason past 16k tokens yet still answer contain no loop.
Does reasoning pay off in accuracy
The authors compare each model with reasoning enabled against the same model with empty reasoning tags, which forces a direct answer. Error bars show 95% Wilson confidence intervals, so small gaps between bars need careful reading. This comparison matters most where reasoning-enabled inference can run out of budget before any answer appears.
No single option wins consistently across models on these two benchmarks. Reasoning-enabled inference can fail to produce an answer through overflow, wasting many tokens. Reasoning-disabled inference always proceeds directly to an answer, so its cost stays predictable. On the harder benchmarks, reasoning lifts Qwen3-32B by 25 and 30 percentage points on LiveCodeBench and CodeContests.
That fits the idea that harder algorithmic tasks benefit from explicit reasoning.

Fig. 3 .Results for RQ2 Reasoning Utility.Model accuracy (pass@1) with and without reasoning across all models and benchmarks. Solid bars show the standard reasoning-enabled setting, while hatched bars show the reasoning-disabled setting, where empty reasoning tags are inserted before generation to force the model to answer directly. Error bars indicate 95% Wilson confidence intervals.
Original paper · CC BY 4.0The pattern breaks for models that overflow more, because OLMo3-7B performs similarly or better with reasoning disabled on several benchmarks. Llama-R1-8B stays weak on the harder generation tasks in either reasoning mode. The NVIDIA models are mixed: CodeReason-7B benefits slightly from reasoning on CodeContests, while OpenReason-7B changes little.
The NVIDIA models often improve when reasoning is disabled on CRUXEval, despite high overflow on CRUX-Input. So reasoning helps only when the model can reach a final answer, and a budget-exhausted trace earns no credit.
Prompt steering versus budgeted transitions
Prompt steering appends a fixed instruction to each task prompt and leaves decoding unchanged. The authors compared five prompt styles: a default baseline, a concise instruction, a token-budget instruction, an aspects instruction, and Plan-and-Solve. The aspects instruction discourages step-by-step reasoning and asks the model to briefly consider inputs, outputs, edge cases, and design choices.
Plan-and-Solve gives a structured-reasoning contrast without explicitly limiting reasoning length.
The aspects prompt cut Qwen3-8B average overflow from 21.4% to 3.6% while retaining similar accuracy. OLMo3-7B also benefits from brevity-oriented prompts. Llama-R1-8B and CodeReason-7B still overflow on more than 34% and 45% of tasks, even under their best prompt. OpenReason-7B behaves differently, because every steering prompt increased its average overflow.
Qwen3-32B lost 17 to 19 percentage points under the concise and aspects prompts, despite having little baseline overflow. Plan-and-Solve gave no consistent reduction in overflow or gain in accuracy. Prompt steering therefore gives useful soft control, but no single prompt improved both accuracy and overflow across models and tasks.
Budgeted transitions act more directly: if the model is still reasoning at a budget Bt, the end-of-reasoning token is appended. Generation then continues in the answer segment, and the overall 32k-token budget stays unchanged. Because loops dominated overflowed traces, the transition also stops repetitive reasoning from consuming the rest of the budget.

Fig. 5 .Results for RQ3 Reasoning Control, Budgeted Transitions.Effect of enforced reasoning-transition budgets on accuracy. Each line shows macro- averagepass@1across all benchmark settings as the transition budget varies from immediate transition to 28k tokens. Dashed lines show each model’s standard reasoning-enabled baseline, and stars mark the best observed transition budget.
Original paper · CC BY 4.0CodeReason-7B gains almost 20 percentage points at a moderate transition budget over its standard reasoning run. OpenReason-7B is the clear exception, because an immediate transition with reasoning disabled performs best on average. On harder generation benchmarks, Qwen3-14B, Qwen3-32B, OpenReason-7B, and CodeReason-7B generally benefit from more reasoning before transition.
On CRUXEval, the Qwen models recover most of the benefit within the first few thousand tokens, so the useful budget depends on both the model and the task.
Token cost per correct answer
The authors report mean output tokens and tokens per correct answer, macro-averaged over the six benchmark settings. Tokens per correct answer divide the total generated tokens by the number of correct responses, so a cheap run that fails still pays its full cost. The largest gaps appear for models that were most prone to reasoning-trace overflow.
Llama-R1-8B averages roughly 15k output tokens under default reasoning, compared to 7.9k at its best transition budget. For Llama-R1-8B, the best transition budget lowers tokens per correct answer from roughly 300k to 61k. Its high default cost comes from long generations combined with a baseline accuracy of about 29% pass@1, not from length alone.
It also improves efficiency less reliably than transition budgets, and by a smaller margin. For the Qwen models, reasoning-disabled inference is much cheaper, and Qwen3-8B falls from roughly 11k output tokens to 1.9k. Per correct answer, Qwen3-8B falls from roughly 32k under default reasoning to 8.1k with reasoning disabled. Reasoning-disabled inference therefore stays the most token-efficient setting for the Qwen models overall.
The authors note that RQ2 showed explicit reasoning still gives substantially higher absolute accuracy on harder tasks. The best transition budget and best prompt style were chosen retrospectively, so these results give an upper bound rather than a deployable budget policy.
Where the findings stop applying
The loop detector only catches sustained periodic repetition, so it can miss shorter loops and loops with a semantic character. Readers should therefore treat the reported loop rates as conservative. Token counts serve as the cost measure, since the authors don't use wall-clock latency or energy.
Greedy decoding with temperature 0.0 and top p 1.0 shapes every result, so other decoding strategies may shift reasoning length, looping, and accuracy.
Hidden-reasoning systems and agentic software-engineering settings weren't tested either. Multi-turn systems bring tool use, retrieval, and repository context, which fall outside this single-shot setup. Older benchmarks may overlap with pre-training data, but the authors judge that unlikely to inflate overflow rates. Memorised solutions may need less search, so the overflow estimates could be conservative.
Paper info
- Authors
- Lukas Twist, Helen Yannakoudakis, Jie M. Zhang
- Venue
- arXiv · Preprint
- First published
- 2026-11-4
- Added
- 2026-11-6
- Updated
- 2026-11-4
- Version
- v1
- arXiv
- 2611.06095
- Category
- cs.AI · cs.SE
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
Explicit reasoning can help language models generate code, but it also introduces a practical risk: the model may spend so much of its output budget reasoning that it never produces usable code. We study this behaviour in relatively small open-weight reasoning models, framing it as reasoning-trace overflow. Across seven models and six code benchmark settings, we measure how much of a fixed 32k-token output budget is spent on reasoning, whether that reasoning improves pass@1, and whether lightweight inference-time controls can mitigate overflow. Our results show that the value of reasoning is highly conditional. Overflow is rare on simpler function-level tasks, but becomes common on harder code-generation benchmarks and for particular model families: on several model--benchmark pairs, more than half of generations exhaust the full 32k-token budget while still reasoning. Most complete overflow is associated with repetitive reasoning loops, although substantial long reasoning also occurs without looping. Disabling reasoning can therefore be competitive for overflow-prone models, simply because it ensures that an answer is produced. At the same time, reasoning remains valuable for stronger models on harder algorithmic and code-understanding tasks. Finally, prompt steering can substantially reduce overflow for some models but is inconsistent, while budgeted transitions provide more direct control and can improve both performance and token efficiency for overflow-prone models. These findings suggest that explicit reasoning should be treated as a controllable resource for code generation, rather than an always-on capability.
Quote from the paper
Lukas Twist, Helen Yannakoudakis, Jie M. Zhang (2026). Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models. arXiv:2611.06095v1. https://arxiv.org/abs/2611.06095v1
BibTeX
@misc{twist2026reasoning,
title = {{Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models}},
author = {Lukas Twist and Helen Yannakoudakis and Jie M. Zhang},
year = {2026},
eprint = {2611.06095},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.06095v1}
}