SEApr 14

Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Code

arXiv:2604.1221490.6h-index: 48
Predicted impact top 8% in SE · last 90 daysOriginality Incremental advance
AI Analysis

For researchers and practitioners using LLMs for code generation, this work provides a nuanced understanding of when and why CoT helps or hurts, offering diagnostic signals for building more robust systems.

This paper investigates the robustness of Chain-of-Thought (CoT) prompting for code generation, finding that CoT does not uniformly improve performance or robustness; its benefits depend on model family, task structure, and prompt explicitness. The study identifies three trajectory deformations (Lengthening, Branching, Simplification) that explain failure patterns and shows that early-stage uncertainty can localize instability.

Chain-of-Thought (CoT) prompting is widely used to elicit explicit reasoning from large language models for code (LLM4Code). However, its impact on robustness and the stability of reasoning trajectories under realistic input perturbations remains poorly understood. Prior work has largely evaluated CoT through final correctness, leaving a critical gap in understanding how CoT reshapes internal uncertainty dynamics and why it sometimes harms rather than helps code generation. We suggest that CoT is not uniformly beneficial; instead, its robustness depends on whether perturbations destabilize structurally sensitive commitment points along the reasoning-to-code trajectory. We conduct a controlled, large-scale empirical study of CoT across six models and two code benchmarks (MHPP and BigCodeBench), subjecting task docstrings to systematic character-, word-, and sentence-level perturbations. We instrument full generation traces with token-level uncertainty and define three novel structural anchors: reasoning-code transition, symbolic commitment, and algorithmic articulation. Findings: (1) CoT does not yield uniform performance or robustness gains: its benefits are contingent on model family, task structure, and prompt explicitness. (2) CoT and No-CoT exhibit distinct robustness profiles, with different perturbation families triggering different failure modes. (3) We identify three recurrent trajectory deformations--Lengthening, Branching, and Simplification--that systematically emerge when perturbations interact with structural anchors and explain failure patterns. (4) Early-stage uncertainty serves as a reliable diagnostic signal for localizing where trajectory instability begins around sensitive anchors. These results provide a unified explanation for CoT's mixed performance and suggest design principles for building more robust reasoning-based code generators.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes