When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Context
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Context: Retrieval-augmented code generation relies on cross-file repository context, but retrieved snippets may come from obsolete project states. Objectives: We study whether temporally stale repository snippets act as harmless noise or actively induce current-state-incompatible code. Methods: We conduct a controlled diagnostic study on a curated 17-sample set of production-helper signature changes from five Python repositories. For each sample, we compare current-only, stale-only, no-retrieval, and mixed current/stale retrieval conditions under prompts that hide commit freshness and expected current signatures. Results: Under neutralized prompts, stale-only retrieval induces stale helper references on 15/17 Qwen2.5-Coder-7B-Instruct samples and 13/17 gpt-4.1-mini samples, corresponding to 88.2 and 76.5 percentage-point increases over current-only retrieval. No retrieval produces zero stale references but only 1/17 passing completions. The two models share 75.0% Jaccard overlap among stale-triggering samples, and mixed conditions show that adding valid current evidence largely rescues stale-only failures. Conclusion: Temporal validity of retrieved repository context is a distinct diagnostic variable for Code RAG robustness: stale context can actively bias models toward obsolete repository state rather than merely removing useful evidence.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 14 of its 16 references that are in the map. First posted on arXiv 14 May 2026.
Builds on
14 of 16 references.
Closest ancestors · 4
Same direction, newest first
- 2025CodeRAG: Finding Relevant and Necessary Knowledge for Retrieval-Augmented Repository-Level Code Completion19 Sep
- 2025Impact-driven Context Filtering For Cross-file Code Completion8 Aug
- 2025Towards Mitigating API Hallucination in Code Generated by LLMs with Hierarchical Dependency Aware8 May
- 2024EVOR: Evolving Retrieval for Code Generation19 Feb
Other references · 10
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 183
- 2023CodePlan: Repository-level Coding using LLMs and Planningcited by 140
- 2024We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMscited by 65
- 2024CodeHalu: Investigating Code Hallucinations in LLMs via Execution-based Verificationcited by 34
- 2025SWE-Bench++: A Framework for the Scalable Generation of Software Engineering Benchmarks from Open-Source Repositoriescited by 28
- 2025RustEvo^2: An Evolving Benchmark for API Evolution in LLM-based Rust Code Generationcited by 10
- 2025Identifying and Mitigating API Misuse in Large Language Modelscited by 3
- 2026When LLMs Lag Behind: Knowledge Conflicts from Evolving APIs in Code Generationcited by 3
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2026Temporal Validity on Real Software Histories: Eliminating Stale-Fact Errors in Code-Assistant Memory over GitHub Fixes
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Study
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation
- 2024Retrieval-augmented code completion for local projects using large language models