Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generation
On the map: LLM reasoning → Prompting and chain-of-thought reasoning
also in 1 more
Abstract (arXiv)
Large Language Models (LLMs) have achieved remarkable success in tasks requiring complex reasoning, such as code generation, mathematical problem solving, and algorithmic synthesis -- especially when aided by reasoning tokens and Chain-of-Thought prompting. Yet, a core question remains: do these models truly reason, or do they merely exploit shallow statistical patterns? In this paper, we introduce Chain-of-Code Collapse, where we systematically investigate the robustness of reasoning LLMs by introducing a suite of semantically faithful yet adversarially structured prompt perturbations. Our evaluation -- spanning 700 perturbed code generations derived from LeetCode-style problems -- applies transformations such as storytelling reframing, irrelevant constraint injection, example reordering, and numeric perturbation. We observe that while certain modifications severely degrade performance (with accuracy drops up to -42.1%), others surprisingly improve model accuracy by up to 35.3%, suggesting sensitivity not only to semantics but also to surface-level prompt dynamics. These findings expose the fragility and unpredictability of current reasoning systems, underscoring the need for more principles approaches to reasoning alignments and prompting robustness. We release our perturbation datasets and evaluation framework to promote further research in trustworthy and resilient LLM reasoning.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Placed in Prompting and chain-of-thought reasoning, one of 17 directions in LLM reasoning. Builds on 23 of its 31 references that are in the map. First posted on arXiv 8 Jun 2025.
Builds on
23 of 31 references.
Closest ancestors · 2
Same direction, newest first
- 2023Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Models6 May
- 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Tasks22 Nov
Other references · 21
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2025DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learningcited by 6,330
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2024GSM-Symbolic: Understanding the Limitations of Mathematical Reasoning in Large Language Modelscited by 550
- 2022ROSCOE: A Suite of Metrics for Scoring Step-by-Step Reasoningcited by 177
- 2024Beyond Accuracy: Evaluating the Reasoning Behavior of Large Language Models -- A Surveycited by 83
- 2023ReCEval: Evaluating Reasoning Chains via Correctness and Informativenesscited by 77
- 2024What's Wrong with Your Code Generated by Large Language Models? An Extensive Studycited by 53
- 2024CodeJudge: Evaluating Code Generation with Large Language Modelscited by 44
9 more
- 2024Voice Jailbreak Attacks Against GPT-4ocited by 42
- 2023DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructionscited by 33
- 2025Uncertainty-Guided Chain-of-Thought for Code Generation with LLMscited by 32
- 2024Reasoning Robustness of LLMs to Adversarial Typographical Errorscited by 31
- 2025Entropy-Gated Branching for Efficient Test-Time Reasoningcited by 22
- 2025Speak Easy: Eliciting Harmful Jailbreaks from LLMs with Simple Interactionscited by 15
- 2024The Impact of Prompt Programming on Function-Level Code Generationcited by 13
- 2025Dagger Behind Smile: Fool LLMs with a Happy Ending Storycited by 6
- 2025Evaluate-and-Purify: Fortifying Code Language Models Against Adversarial Attacks Using LLM-as-a-Judgecited by 4
Built on by
Citing papers per year: 2025: 2; 2026: 2.
4 papers.
- 2025A Comprehensive Survey on Trustworthiness in Reasoning with Large Language Modelscited by 25
- 2025POT: Inducing Overthinking in LLMs via Black-Box Iterative Optimizationcited by 11
- 2026Fragile Thoughts: How Large Language Models Handle Chain-of-Thought Perturbationscited by 5
- 2026Testing LLM Arithmetic Reasoning Generalization with Automatic Numeric-Remapping Attackscited by 1
- 2026Testing LLM Arithmetic Reasoning Generalization with Automatic Numeric-Remapping Attacks2 Jun 2026
- 2026Fragile Thoughts: How Large Language Models Handle Chain-of-Thought Perturbations11 Feb 2026
- 2025A Comprehensive Survey on Trustworthiness in Reasoning with Large Language Models4 Sep 2025
- 2025POT: Inducing Overthinking in LLMs via Black-Box Iterative Optimization23 Aug 2025
Similar, not cited
Close in wording, no citation either way
- 2026CAP-CoT: Cycle Adversarial Prompt for Improving Chain of Thoughts in LLM Reasoning
- 2025Exploring LLM Reasoning Through Controlled Prompt Variations
- 2025Robust Answers, Fragile Logic: Probing the Decoupling Hypothesis in LLM Reasoning
- 2025"Well, Keep Thinking": Enhancing LLM Reasoning with Adaptive Injection Decoding
- 2025The Meta-Prompting Protocol: Orchestrating LLMs via Adversarial Feedback Loops
- 2024General Purpose Verification for Chain of Thought Prompting
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoning
- 2023Noisy Exemplars Make Large Language Models More Robust: A Domain-Agnostic Behavioral Analysis