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.
Figures & tables
Figure 1. Overview of the Empirical Study.
Abbr.
Reasoning Action
Description
PU
Problem understanding
Understanding and clarifying the problem requirements.
SD
Solution design
Designing the high-level solution approach and strategy.
IP
Implementation planning
Planning the detailed implementation steps and logic.
CC
Code construction
Writing and refining the actual code.
VV
Verification and validation
Testing, debugging, and validating the solution.
KR
Knowledge retrieval
Retrieving and applying relevant knowledge.
Table 1. Taxonomy of Reasoning Actions
Task
General Pattern
Representative Signature
Support (within-task vs. cross-task)
R1-0528
R1-Qwen3-8B
Generation
Design-to-implementation
PU⇒SD⇒IP⇒VV
91.4% vs. 17.0%
88.0% vs. 22.0%
Execution Reasoning
State tracing
PU⇒{VV,MR}∗
45.9% vs. 2.2%
53.5% vs. 3.4%
Debugging
Evidence-fix-recheck
{SD,IP}⇒CC⇒VV
68.1% vs. 21.5%
70.8% vs. 20.4%
Translation
Semantic mapping-to-implementation
PU⇒SD⇒IP⇒CC
36.5% vs. 9.5%
30.1% vs. 16.2%
Table 2. General Reasoning Patterns Identified across Four Coding Tasks
Metric
R1-0528
R1-Qwen3-8B
Valid
Invalid
Valid
Invalid
Reasoning tokens
3,690
6,609
4,330
6,991
Raw action length
18.58
24.96
22.64
32.21
Collapsed action length
11.78
14.91
15.97
21.99
Closure share
0.414
0.241
0.330
0.219
Drift share
0.247
0.391
0.313
0.464
Table 3. Length and Action Allocation of Valid and Invalid Reasoning Traces
Task
Model
Positive/Negative Pattern
Representative Signature
Generation
R1-0528
Plan-verify-close
IP → VV → AUX
Plan-verify iteration
IP → VV → IP → VV → IP
Knowledge-verify-reflect detour
KR → VV → MR
Design-knowledge detour
SD → KR → IP
R1-Qwen3-8B
Verify-plan-reverify
VV → IP → VV
Extended verify-plan
VV → IP → VV → IP
Table 4. Positive and Negative Patterns Identified across Four Coding Tasks. Gray -shaded cells denote negative patterns.
Figure 2. Support Comparison between Positive and Negative Patterns.
Figure 3. Task Identification Accuracy Using General-Pattern Features. Error bars denote the standard deviation across cross-validation folds, and the dashed line indicates the 25% random baseline. Results for DS-V4-F and GLM-5.1 represent cross-model transfer using classifiers trained on R1-0528 traces.
Direct
Transferred
Task
Method
R1-0528
R1-Qwen3-8B
DS-V4-F
GLM-5.1
P@1 ↑
Tok. ↓
P@1 ↑
Tok. ↓
P@1 ↑
Tok. ↓
P@1 ↑
Tok. ↓
Generation
Default
72.46
14.9
56.21
17.9
80.78
13.0
90.29
16.5
Positive-only
73.14
15.2
55.86
18.3
84.36
13.5
90.06
13.2
Negative-only
72.08
14.6
56.39
17.6
79.84
12.5
90.74
13.0
PN guidance
74.49
15.6
56.88
17.3
87.80
12.2
91.17
12.9
Table 5. Pattern-Guided Prompting Results and Cross-Model Transfer. Direct applies each model’s own pattern inventory, whereas Transferred applies pattern inventories mined from the R1 models to the previously unseen models DS-V4-F and GLM-5.1. Tok.: mean generated-output tokens per instance (thousands).
Task
Model
Full Reasoning
Pattern-Aware Stop
P@1 ↑
Tok. ↓
P@1 ↑
Tok. ↓
Δ P@1 (pp)
Δ Tok. (%)
Generation
R1-Qwen3-8B
56.21
17.89K
52.14
10.64K
−4.07
−40.56%
DS-V4-F
80.78
13.00K
73.36
8.43K
−7.42
−35.13%
GLM-5.1
90.29
16.54K
88.06
7.85K
−2.23
−52.52%
Execution Reasoning
R1-Qwen3-8B
44.24
3.43K
40.58
2.10K
−3.66
−38.75%
DS-V4-F
56.81
2.13K
51.57
0.85K
−5.24
−59.78%
Table 6. Negative Pattern-Aware Early Stopping Results across Models. Tok.: API-reported token usage (thousands); stopped runs include finalizer output.