arXiv:2611.06095cs.AINov 2026

Manuscript Offprint

arXiv:2611.06095

Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models

Lukas Twist, Helen Yannakoudakis, Jie M. Zhang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Lukas Twist

King's College London

London, UK

Helen Yannakoudakis

King's College London

London, UK

Jie M. Zhang

King's College London

London, UK

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.

I. INTRODUCTION

Relatively small open-weight reasoning models are becoming increasingly attractive for code generation. They can be run locally, provide greater control over inference, and expose explicit reasoning traces that can be inspected and manipulated [1]. Recent work has shown that reasoning can support code generation through structured prompting, planning, and lightweight model training [2], [3], [4], while survey work highlights code reasoning as an increasingly important direction for software engineering [5]. However, explicit reasoning is not free: longer traces consume additional tokens and inference compute, and can contain substantial unnecessary reasoning [6], [7].

This raises a practical question: when models are asked to generate code, is explicit reasoning actually worth the cost? For code generation, this creates an additional constraint. A model must not only reason about the task, but also leave enough output budget to produce a complete program. For harder tasks, these two demands can grow together: the model may spend more tokens planning, searching, or checking pos-

sible implementations, while the final answer itself may also require more tokens. When reasoning consumes the available output budget, the model can fail slowly, spending substantial inference time and compute without returning usable code to the developer.

We refer to this failure mode as reasoning-trace overflow. Unlike ordinary verbosity, reasoning-trace overflow prevents answer generation altogether. Recent work has explored controlling reasoning length through token budgets, early stopping, and explicit reasoning limits [7], [8], [9], [10]. Most of this work focuses on controlling reasoning length in mathematical and general reasoning settings, with comparatively little attention paid to how excessive reasoning naturally manifests during code generation. This setting introduces an additional constraint: the reasoning trace must share the output budget with a potentially long executable answer.

To fill this gap, we conduct an empirical study of reasoning-trace overflow in code generation. We evaluate seven open-weight reasoning models across six code benchmark settings under a fixed 32k-token output budget. Our study asks three questions. First, how much of the output budget do these models spend on reasoning, and when do they overflow? Second, does extended reasoning improve accuracy enough to justify this cost? Third, can lightweight inference-time controls – either prompt-based steering, which influences reasoning behaviour without modifying decoding, or budgeted transitions, which directly control when reasoning ends – reduce overflow while preserving accuracy?

Our results show that the value of explicit reasoning is highly conditional. Reasoning-trace overflow is uncommon on simple function-level synthesis tasks, but becomes frequent on harder code-generation benchmarks and for particular model families. Most complete overflow is associated with repetitive reasoning loops, although substantial long reasoning also occurs without looping. When overflow is common, disabling reasoning can be competitive not because reasoning is necessarily unhelpful, but because it ensures that the model reaches the answer stage: a response that exhausts its budget while still reasoning has no opportunity to pass the tests. At the same time, reasoning remains valuable for larger models on harder algorithmic and code-understanding benchmarks, where it can substantially improve pass@1 when the model successfully transitions to an answer.

We also find that overflow can be mitigated at inference time, but not reliably across all settings. Prompt steering can substantially reduce overflow for some models, but its effects are inconsistent and can come at the cost of accuracy. Budgeted transitions provide more direct control and can improve performance for overflow-prone models, while substantially reducing the token cost of successful answers. Overall, our findings suggest that reasoning should be treated as a controllable resource for code generation, rather than an always-on capability.

Our contributions are as follows:

  1. We define and operationalise reasoning-trace overflow, a failure mode in which explicit reasoning consumes the output budget before a code solution is produced.

  2. We provide a broad empirical characterisation of reasoning-trace overflow across seven relatively small open-weight reasoning models and six code benchmark settings, showing how it varies with task type, model family, and model scale, how often complete overflow coincides with repetitive reasoning loops, and whether the associated reasoning improves accuracy.

  3. We compare complementary forms of inference-time reasoning control, from prompt-based soft constraints to enforced transition budgets, and show how they trade off overflow, accuracy, and token efficiency.

References (48)