When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Context

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Weng, Haojun, Yang, Qianqian, Fu, Hao, Pan, Haobin, Lv, Xinwei
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866911684380065792
author Weng, Haojun
Yang, Qianqian
Fu, Hao
Pan, Haobin
Lv, Xinwei
author_facet Weng, Haojun
Yang, Qianqian
Fu, Hao
Pan, Haobin
Lv, Xinwei
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2605_14478
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Context
Weng, Haojun
Yang, Qianqian
Fu, Hao
Pan, Haobin
Lv, Xinwei
Software Engineering
Artificial Intelligence
Computation and Language
D.2.5; D.2.7; I.2.7
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.
title When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Context
topic Software Engineering
Artificial Intelligence
Computation and Language
D.2.5; D.2.7; I.2.7
url https://arxiv.org/abs/2605.14478