Wired for Reuse: Automating Context-Aware Code Adaptation in IDEs via LLM-Based Agent
Taiming Wang, Yanjie Jiang, Chunhao Dong, Yuxia Zhang, Hui Liu

TL;DR
This paper presents WIRL, an LLM-based agent that automates context-aware code adaptation in IDEs by intelligently wiring unresolved variables, significantly improving accuracy over existing methods and IDE tools.
Contribution
WIRL introduces a novel retrieval-augmented generation approach for code wiring, combining rule-based and decision-guided strategies to enhance context-aware code adaptation.
Findings
Achieves 91.7% exact match precision and 90.0% recall.
Outperforms advanced LLMs by over 20 percentage points in precision.
Surpasses IntelliJ IDEA's performance by nearly 55 percentage points.
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsService-Oriented Architecture and Web Services · Business Process Modeling and Analysis · Access Control and Trust
