Manuscript Offprint

arXiv:2610.38800

When Relevant Code Is Wrong: Runtime-Aware Context for AI Coding Agents

Wesley K. G. Assunção, Ramesh Periyathambi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Wesley K. G. Assunção

North Carolina State University

Raleigh, NC, USA

Ramesh Periyathambi

eBay Inc.

San Francisco, CA, USA

Abstract—AI coding agents increasingly rely on retrieved code and development history to guide software changes. However, highly relevant artifacts may describe implementations that are inactive or incompatible with the target deployment. Neither semantic similarity nor recency establishes whether retrieved information remains applicable under feature flags, architectural migrations, and deployment-specific configurations. We challenge relevance-oriented retrieval by introducing operational context validity, a task-, deployment-, and time-dependent criterion for determining whether software evidence can legitimately guide implementation decisions. We instantiate this new retrieval principle in CASE, an agent-agnostic framework that connects repository artifacts with runtime configurations and architectural evolution, classifies evidence as valid, invalid, or unknown, and generates context packages distinguishing actionable guidance from historical rationale and unresolved constraints. We investigate its feasibility through a reproducible preliminary evaluation involving six development tasks, 15 artifacts, and three deployments. Conventional retrieval exposes 16 incompatible artifact occurrences as actionable, whereas CASE excludes them while retaining all applicable artifacts under the prototype's reference rules. Recency filtering reduces valid recall to 0.43, while removing feature-flag evidence from CASE reduces it to 0.13. Although these results demonstrate feasibility rather than improvements in coding-agent correctness, they reveal limitations of relevance-based retrieval and motivate a new research direction: enabling coding agents to reason not only about which information is relevant, but also whether it remains operationally valid.

Index Terms—AI coding agents, software evolution, feature flags, runtime configuration, retrieval-augmented generation, software architecture.

I. INTRODUCTION

AI coding agents are increasingly capable of performing complex software engineering tasks [1]. They can explore repositories, retrieve relevant historical pull requests (PRs), and propose changes across multiple files [2]. Existing research has demonstrated the importance of repository-level context for solving development tasks [3], motivating techniques that retrieve relevant code, documentation, and software dependencies [4], [5]. However, these approaches predominantly focus on identifying information that seems relevant to a task, often overlooking a fundamental question: Is the retrieved information operationally valid for the task at hand?

This distinction becomes particularly important in large, continuously evolving software systems, where multiple implementations, architectural versions, and runtime configurations coexist [6]–[8]. Our research is motivated by software evolution challenges encountered in collaboration with a large online marketplace. In their systems, repositories and development artifacts often capture multiple stages of a system's evolution rather than a single, authoritative view of how it currently operates. Different implementations may coexist, services may have been replaced, and feature flags or deployment-specific configurations may determine which execution paths are active [9], [10]. Hence, source code, PRs, and documentation may seem relevant to a development task even though they describe implementations that are no longer applicable to the target environment. In this context, existing retrieval approaches can identify artifacts related to a task but do not necessarily establish whether their architectural assumptions, dependencies, and runtime conditions remain valid. Consequently, coding agents may propose technically plausible changes that are incompatible with the system's actual operational state.

The underlying problem is that relevant information is not necessarily applicable information. Recent research has demonstrated that retrieved repository context can be temporally stale and induce obsolete API usage [10], that irrelevant or misleading retrieved information can harm code generation [11], and that repository-specific agent knowledge can become outdated as software evolves [12]. Evolution-aware approaches, such as Chronos, further demonstrate the value of retrieving historical development decisions [2]. However, these contributions do not directly address deployment-conditioned prescriptive validity: determining whether retrieved evidence can legitimately guide implementation decisions under a particular runtime configuration and deployment state.

We argue that this limitation calls for a shift from relevance-based retrieval toward operationally valid context selection. We introduce operational context validity, which characterizes whether a retrieved software artifact can legitimately guide an implementation decision for a particular deployment and point in time. Building on this idea, we propose CASE, a context-aware framework for existing coding agents. Rather than simply retrieving additional information, CASE connects software artifacts with runtime configurations, feature flags, and architectural history to distinguish applicable implementations from incompatible or uncertain evidence. It then generates task-specific context packages that identify which artifacts can guide implementation, which require further verification, and which should be retained only as explanatory history.

Our central hypothesis is that explicitly distinguishing relevance from operational validity can reduce implementation decisions that conflict with the target system's architecture and runtime configuration. We investigate this forward-looking idea through three contributions: (1) a formulation of operational context validity as a deployment- and time-dependent property of retrieved software evidence; (2) a lightweight, validity-aware context selection mechanism that can be integrated with existing coding agents; and (3) an initial proof-of-concept pilot evaluation demonstrating the feasibility of deployment-aware context selection. These contributions establish a foundation for investigating whether operationally valid context can improve the reliability of AI-assisted software evolution.

References (20)