mlsanityData to 14 Oct 2026

Wired for Reuse: Automating Context-Aware Code Adaptation in IDEs via LLM-Based Agent

arXiv 2507.01315 ↗First posted 2 Jul 2025cs.SEcited by 0

On the map: LLM agents and tool use → Software engineering coding agents

Abstract (arXiv)

Copy-paste-modify is a widespread and pragmatic practice in software development, where developers adapt reused code snippets, sourced from platforms such as Stack Overflow, GitHub, or LLM outputs, into their local codebase. A critical yet underexplored aspect of this adaptation is code wiring: the context-aware process of substituting unresolved variables in pasted code with suitable variables or expressions from the surrounding context. Existing solutions either rely on heuristic rules or historical templates, often failing to effectively utilize contextual information, despite studies showing that over half of adaptation cases are context-dependent. In this paper, we introduce WIRL, an LLM-based agent for code wiring framed as a Retrieval-Augmented Generation (RAG) infilling task. WIRL combines an LLM, a customized toolkit, and an orchestration module to identify unresolved variables, retrieve context, and perform context-aware substitutions. To balance efficiency and autonomy, the agent adopts a mixed strategy: deterministic rule-based steps for common patterns, and a state-machine-guided decision process for intelligent exploration. We evaluate WIRL on a carefully curated, high-quality dataset consisting of real-world code adaptation scenarios. Our approach achieves an exact match precision of 91.7% and a recall of 90.0%, outperforming advanced LLMs by 22.6 and 13.7 percentage points in precision and recall, respectively, and surpassing IntelliJ IDEA by 54.3 and 49.9 percentage points. These results underscore its practical utility, particularly in contexts with complex variable dependencies or multiple unresolved variables. We believe WIRL paves the way for more intelligent and context-aware developer assistance in modern IDEs.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 25 of its 55 references that are in the map. First posted on arXiv 2 Jul 2025.

Builds on

25 of 55 references.

Closest ancestors · 5

Same direction, newest first

  1. 2024From LLMs to LLM-based Agents for Software Engineering: A Survey of Current, Challenges and Future5 Aug
  2. 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering6 May
  3. 2024MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue Resolution26 Mar
  4. 2024RepairAgent: An Autonomous, LLM-Based Agent for Program Repair25 Mar
  5. 2024SOEN-101: Code Generation by Emulating Software Process Models Using Large Language Model Agents23 Mar

Other references · 20

  1. 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
  2. 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
  3. 2023A Survey on Large Language Model based Autonomous Agentscited by 2,242
  4. 2024AutoCodeRover: Autonomous Program Improvementcited by 278
  5. 2023A Survey on Model Compression for Large Language Modelscited by 269
  6. 2022CoditT5: Pretraining for Source Code and Natural Language Editingcited by 45
  7. 2024Large Language Model Inference Acceleration: A Comprehensive Hardware Perspectivecited by 38
  8. 2023CCT5: A Code-Change-Oriented Pre-Trained Modelcited by 18
  9. 2023GrACE: Generation using Associated Code Editscited by 16
  10. 2018SOTorrent: Reconstructing and Analyzing the Evolution of Stack Overflow Postscited by 9
  11. 2024Deep Learning-based Software Engineering: Progress, Challenges, and Opportunitiescited by 9
  12. 2017SmartPaste: Learning to Adapt Source Codecited by 8
8 more
  1. 2019Analyzing and Supporting Adaptation of Online Code Examplescited by 8
  2. 2022Overwatch: Learning Patterns in Code Edit Sequencescited by 8
  3. 2021APIzation: Generating Reusable APIs from StackOverflow Code Snippetscited by 6
  4. 2024CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Naturecited by 6
  5. 2024Instruct or Interact? Exploring and Eliciting LLMs' Capability in Code Snippet Adaptation Through Prompt Engineeringcited by 6
  6. 2020Optimising the Fit of Stack Overflow Code Snippets into Existing Codecited by 5
  7. 2023How Do Java Developers Reuse StackOverflow Answers in Their GitHub Projects?cited by 2
  8. 2025Recommending Variable Names for Extract Local Variable Refactoringscited by 2

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2025MANTRA: Enhancing Automated Method-Level Refactoring with Contextual RAG and Multi-Agent LLM Collaboration
  2. 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation
  3. 2026AdaptAgent: A Multi-agent, Domain-Guided Reasoning Framework for Code Adaptation
  4. 2026ReCUBE: Evaluating Repository-Level Context Utilization in Code Generation
  5. 2025Context Engineering for Multi-Agent LLM Code Assistants Using Elicit, NotebookLM, ChatGPT, and Claude Code
  6. 2026SWE Context Bench: A Benchmark for Context Learning in Coding
  7. 2024On The Importance of Reasoning for Context Retrieval in Repository-Level Code Editing
  8. 2026Coding in a Bubble? Evaluating LLMs in Resolving Context Adaptation Bugs During Code Adaptation