arXiv:2610.34943cs.SEOct 2026

Manuscript Offprint

arXiv:2610.34943

Reasoning Patterns for Efficient AI Coding: An Empirical Study

Zhe Yin, Yuling Shi, Xiaodong Gu, Beijun Shen

ZHE YIN, Shanghai Jiao Tong University, China

YULING SHI, Shanghai Jiao Tong University, China

XIAODONG GU, Shanghai Jiao Tong University, China

BEIJUN SHEN ∗^{*}, Shanghai Jiao Tong University, China

Large Reasoning Models (LRMs) generate long reasoning traces that expose intermediate inference behavior, offering opportunities to study and control reasoning in AI coding. However, the underlying patterns in these traces and their potential for analyzing and guiding coding models remain poorly understood, limiting systematic characterization and inference-time control of LRM reasoning. We conduct an empirical study of reasoning patterns across four representative coding tasks. We transform reasoning traces into structured action sequences and mine recurring fragments using within-task support, cross-task contrasts, and valid-invalid support contrasts. We characterize four general reasoning patterns by coding agents: design-to-implementation for code generation, state tracing for execution reasoning, evidence-fix-recheck for debugging, and semantic mapping for translation. We further identify positive and negative patterns associated with valid and invalid reasoning traces, respectively. Positive patterns reflect verification-driven convergence, whereas negative patterns reflect repeated design revision, reflection, and knowledge recall without closure. To demonstrate their practical utility, we evaluate three pattern-based applications: task identification, pattern-guided prompting, and pattern-aware early stopping. Features capturing general reasoning patterns enable accurate task identification from reasoning traces without accessing task descriptions or final answers. Prompting guided by positive and negative patterns improves the overall accuracy of downstream tasks, while negative pattern-aware early stopping substantially reduces API-reported token usage with only a modest decrease in pass@1. All three applications also generalize to previously unseen models, showing that reasoning patterns can support both the analysis and control of LRM behavior in AI coding.

CCS Concepts: • Software and its engineering → Software development techniques; • Computing methodologies → Artificial intelligence.

Additional Key Words and Phrases: Reasoning Patterns, AI Coding, Reasoning Trace Analysis, Reasoning Pattern Mining, Inference-Time Optimization

ACM Reference Format:

Zhe Yin, Yuling Shi, Xiaodong Gu, and Beijun Shen. 2026. Reasoning Patterns for Efficient AI Coding: An Empirical Study. 1, 1 (October 2026), 21 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn

1 Introduction

Large reasoning models (LRMs) are rapidly reshaping AI coding [35, 36]. Unlike conventional code language models that generate an answer directly, LRMs produce a sequence of intermediate

∗^{*}Corresponding author.

Authors' Contact Information: Zhe Yin, Shanghai Jiao Tong University, Shanghai, China, yin_zhe@sjtu.edu.cn; Yuling Shi, Shanghai Jiao Tong University, Shanghai, China, yuling.shi@sjtu.edu.cn; Xiaodong Gu, Shanghai Jiao Tong University, Shanghai, China, xiaodong.gu@sjtu.edu.cn; Beijun Shen, Shanghai Jiao Tong University, Shanghai, China, bjshen@sjtu.edu.cn.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.

© 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM.

ACM XXXX-XXXX/2026/10-ART

https://doi.org/10.1145/nnnnnnn.nnnnnnn

Zhe Yin, Yuling Shi, Xiaodong Gu, and Beijun Shen

reasoning steps before arriving at a solution. This capability is particularly valuable for coding tasks, where solving a problem often involves intermediate decisions, such as decomposing requirements and designing an algorithm for code generation or tracking program states during execution reasoning. The reasoning process is therefore exposed as part of the model's output rather than remaining implicit.

The availability of these reasoning traces has led to a growing body of research on their role in code-related tasks [6, 29]. Existing studies show that intermediate reasoning can improve task performance, but also reveal substantial inefficiencies. Reasoning traces may contain incorrect assumptions, redundant exploration, repeated revisions, and prolonged deliberation that adds inference cost without improving the final result [4, 12, 18, 39]. These observations have motivated the use of reasoning traces for purposes beyond generating an answer, including self-correction [20, 22], evaluation [26, 30], and inference-time control [9, 10].

However, most existing studies examine reasoning from the perspective of individual tasks or specific behaviors. They focus on final task performance [3, 15, 16], prompting strategies [13, 27, 29], or particular reasoning behaviors in tasks such as code generation [12, 18, 31, 39]. This leaves a more basic question largely unanswered: do reasoning traces contain recurring structures that characterize how LRMs solve coding tasks? If such structures exist, it is also unclear which of them are associated with successful or unsuccessful reasoning, and whether they can be used to improve the efficiency and reliability of inference. Addressing these questions requires looking beyond individual reasoning traces and examining them as sequences of recurring reasoning actions.

To address these questions, we conduct an empirical study of reasoning patterns in AI coding. We collect reasoning traces generated by LRMs across four representative coding tasks: code generation, code execution reasoning, program debugging, and code translation. We transform these traces into structured reasoning action sequences using a unified action taxonomy. This representation allows us to analyze reasoning in terms of observable actions rather than the surface form of generated text. We then examine reasoning patterns at two levels. General patterns capture recurring task-level reasoning structures, whereas positive and negative patterns capture reasoning behaviors at the action level that distinguish valid from invalid trajectories. Finally, we investigate whether the discovered patterns can be leveraged for inference-time analysis and control of LRM behavior.

Specifically, we investigate the following research questions:

• RQ1 (General Patterns): What task-level reasoning patterns emerge across different coding tasks?

Different coding tasks impose distinct reasoning demands, yet it remains unclear whether these differences are reflected in recurring task-level structures. To characterize such structures, we represent reasoning traces as action sequences using a unified action taxonomy and mine recurring action fragments across the four coding tasks. We then examine the resulting patterns to identify the reasoning strategies that characterize each task.

• RQ2 (Positive and Negative Patterns): What action-level reasoning patterns distinguish valid from invalid reasoning trajectories?

General patterns capture differences across coding tasks, but they do not reveal the local reasoning behaviors underlying trace validity. We therefore compare judge-labeled valid and invalid reasoning traces and mine recurring action fragments that characterize the two groups. We assess trace validity using an ensemble LLM-as-a-judge protocol and identify positive patterns prevalent in the valid-labeled group and negative patterns prevalent in the invalid-labeled group.

• RQ3 (Analysis and Control): Can the discovered reasoning patterns support diagnostic analysis and inference-time control of LRM behavior?

Figure

Fig. 1. Overview of the Empirical Study.

We further examine how the discovered patterns can be used. Specifically, we evaluate a diagnostic task-identification probe and two inference-time controls. First, we use general-pattern features to identify coding tasks from reasoning traces. Second, we augment prompts with guidance derived from positive and negative patterns to steer reasoning behavior. Third, we use negative pattern-aware early stopping to terminate inference when such patterns are detected and quantify the resulting accuracy-token trade-off.

Our study yields three main findings. At the task level, coding tasks exhibit distinct reasoning structures: code generation follows a design-to-implementation flow, code execution reasoning centers on state tracing, debugging follows an evidence-fix-recheck loop, and code translation centers on semantic mapping. At the action level, judge-labeled valid and invalid trajectories exhibit distinct positive and negative patterns. Valid traces show verification-driven convergence, whereas invalid traces exhibit recurring behaviors such as repeated redesign, reflection, and knowledge recall without resolution. Beyond characterization, the discovered patterns support a diagnostic probe and two inference-time controls across the evaluated task-model settings. General-pattern features support diagnostic task identification, pattern-guided prompting yields higher mean pass@1, and negative pattern-aware early stopping reduces API-reported token usage with a corresponding decrease in pass@1. Each evaluation also includes previously unseen models.

In summary, this paper makes the following contributions:

• We establish a unified reasoning-action representation for cross-task analysis of LRM reasoning traces and conduct an empirical study across four representative AI coding tasks.

• We characterize reasoning in AI coding at two levels, identifying general patterns at the task level and positive and negative patterns at the action level from judge-labeled valid and invalid reasoning trajectories, respectively.

• We demonstrate the utility of these patterns for AI coding through a diagnostic task-identification probe and two inference-time controls: pattern-guided prompting and negative pattern-aware early stopping.

Zhe Yin, Yuling Shi, Xiaodong Gu, and Beijun Shen

References (13)