mlsanityData to 7 Oct 2026

Coding in a Bubble? Evaluating LLMs in Resolving Context Adaptation Bugs During Code Adaptation

arXiv 2601.06497 ↗First posted 10 Jan 2026cs.SE cs.AIcited by 0

Not on the map. Why?

Abstract (arXiv)

Code adaptation is a fundamental but challenging task in software development, requiring developers to modify existing code for new contexts. A key challenge is to resolve Context Adaptation Bugs (CtxBugs), which occurs when code correct in its original context violates constraints in the target environment. Unlike isolated bugs, CtxBugs cannot be resolved through local fixes and require cross-context reasoning to identify semantic mismatches. Overlooking them may lead to critical failures in adaptation. Although Large Language Models (LLMs) show great potential in automating code-related tasks, their ability to resolve CtxBugs remains a significant and unexplored obstacle to their practical use in code adaptation. To bridge this gap, we propose CtxBugGen, a novel framework for generating CtxBugs to evaluate LLMs. Its core idea is to leverage LLMs' tendency to generate plausible but context-free code when contextual constraints are absent. The framework generates CtxBugs through a four-step process to ensure their relevance and validity: (1) Adaptation Task Selection, (2) Task-specific Perturbation,(3) LLM-based Variant Generation and (4) CtxBugs Identification. Based on the benchmark constructed by CtxBugGen, we conduct an empirical study with four state-of-the-art LLMs. Our results reveal their unsatisfactory performance in CtxBug resolution. The best performing LLM, Kimi-K2, achieves 55.93% on Pass@1 and resolves just 52.47% of CtxBugs. The presence of CtxBugs degrades LLMs' adaptation performance by up to 30%. Failure analysis indicates that LLMs often overlook CtxBugs and replicate them in their outputs. Our study highlights a critical weakness in LLMs' cross-context reasoning and emphasize the need for new methods to enhance their context awareness for reliable code adaptation.

Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 32 of its 74 references that are in the map. First posted on arXiv 10 Jan 2026.

Builds on

32 of 74 references.

References · 32

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
  4. 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 216
  5. 2022Automating Code Review Activities by Large-Scale Pre-trainingcited by 98
  6. 2024DebugBench: Evaluating Debugging Capability of Large Language Modelscited by 74
  7. 2024Calibration and Correctness of Language Models for Codecited by 49
  8. 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?cited by 44
  9. 2019Neural Program Repair by Jointly Learning to Localize and Repaircited by 39
  10. 2020A Survey on Deep Learning for Software Engineeringcited by 37
  11. 2024Search-Based LLMs for Code Optimizationcited by 27
  12. 2023CCT5: A Code-Change-Oriented Pre-Trained Modelcited by 17
20 more
  1. 2024Aligning the Objective of LLM-based Program Repaircited by 12
  2. 2017Stack Overflow Considered Harmful? The Impact of Copy&Paste on Android Application Securitycited by 11
  3. 2018Toxic Code Snippets on Stack Overflowcited by 9
  4. 2017SmartPaste: Learning to Adapt Source Codecited by 8
  5. 2019Analyzing and Supporting Adaptation of Online Code Examplescited by 8
  6. 2024Unseen Horizons: Unveiling the Real Capability of LLM Code Generation Beyond the Familiarcited by 7
  7. 2016From Query to Usable Code: An Analysis of Stack Overflow Code Snippetscited by 6
  8. 2021APIzation: Generating Reusable APIs from StackOverflow Code Snippetscited by 6
  9. 2017Stack Overflow in Github: Any Snippets There?cited by 5
  10. 2020Optimising the Fit of Stack Overflow Code Snippets into Existing Codecited by 5
  11. 2022Towards Exploring the Code Reuse from Stack Overflow during Software Developmentcited by 5
  12. 2024AI Tool Use and Adoption in Software Development by Individuals and Organizations: A Grounded Theory Studycited by 5
  13. 2017Stack Overflow: A Code Laundering Platform?cited by 3
  14. 2022AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representationscited by 3
  15. 2025On the Possibility of Breaking Copyleft Licenses When Reusing Code Generated by ChatGPTcited by 3
  16. 2021NCQ: Code reuse support for node.js developerscited by 2
  17. 2024Are Human Rules Necessary? Generating Reusable APIs with CoT Reasoning and In-Context Learningcited by 2
  18. 2021Comprehensive Integration of API Usage Patternscited by 1
  19. 2023On Code Reuse from StackOverflow: An Exploratory Study on Jupyter Notebookcited by 1
  20. 2026AdaptEval: A Benchmark for Evaluating Large Language Models on Code Snippet Adaptationcited by 1

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2026When LLMs Lag Behind: Knowledge Conflicts from Evolving APIs in Code Generation
  2. 2024COAST: Enhancing the Code Debugging Ability of LLMs through Communicative Agent Based Data Synthesis
  3. 2026The Limits of Long-Context Reasoning in Automated Bug Fixing
  4. 2025LLM-Based Detection of Tangled Code Changes for Higher-Quality Method-Level Bug Datasets
  5. 2025Wired for Reuse: Automating Context-Aware Code Adaptation in IDEs via LLM-Based Agent
  6. 2026Diagnosing Knowledge Gaps in LLM Tool Use: An Agentic Benchmark for Novel API Acquisition
  7. 2025Assessing the Impact of Code Changes on the Fault Localizability of Large Language Models
  8. 2026Multi-task LLMs for Bug Classification: Efficient Inference with Auxiliary Decoding Heads