arXiv:2610.38244cs.SEOct 2026

Manuscript Offprint

arXiv:2610.38244

Precedent or Intent? What Coding Agents Follow When Evolving Existing Code

Haichao Zhu, Geyang Xu, Zhaorui Yang, Jiyuan Wang, Qian Zhang

Abstract

Existing code reveals past implementation decisions but rarely explains the reasoning behind them. When coding agents implement new features or modify existing functionality, past decisions may conflict with new task instructions. This raises a fundamental question for agentic software evolution: when multiple implementations satisfy the same functional requirements, how do coding agents decide whether to follow existing code or new task instructions?

We investigate this question through bidirectional, controlled experiments in purpose-built repositories, followed by validation in real-world open-source repositories. Our approach isolates three competing sources of guidance: (1) Agents' Default Preferences, measured without repository precedents; (2) Repository Precedents, examined by manipulating the frequency and location of existing code examples; and (3) Explicit Task Instructions, tested by introducing rules that conflict with existing code.

We conduct 5,625 trials across four coding agents and six implementation pairs, with validation in four open-source repositories spanning three programming languages. We find that agents share the same default implementation choices, yet overwhelmingly follow repository precedent when it conflicts with those defaults (359/360 trials). Crucially, not all precedents carry equal influence: three supporting local files yield 96% adoption, compared with only 4% for sibling-resource files, and changing file placement alone can shift adoption from 0% to 100% at a fixed example count. When new task intent conflicts with existing code, written priority rules achieve substantially higher success than code examples alone (59/60 versus 38/60 joint successes for two agents on two implementation pairs). The effectiveness of explicit rules also extends to open-source repositories, where a harness-loaded rule raises joint success from 0/120 to 117/120. These findings motivate design-decision traceability that preserves not only implementation choices but also the rationale and priorities that should guide future changes.

Figure

Figure 1: Coding agents that extend a repository are pulled between the implementation already in the code and the intent of the new task. In controlled experiments with four agents and six implementation pairs, existing code wins by default, and a written rule is what reliably changes course.

1 Introduction

Software development involves the continuous evolution of existing systems. As LLM-based coding agents take on increasingly complex software engineering tasks, their role is expanding beyond individual issue resolution to implementing changes across evolving repositories [35, 13, 40, 6, 15]. Unlike building from scratch, extending an existing repository means working inside decisions made during earlier development, whose rationale is often lost. These decisions influence how new functionality is implemented, even when multiple alternatives satisfy the same functional requirements [6, 40]. However, existing code rarely explains why a particular implementation was chosen or whether that decision

*Corresponding author: gxu048@ucr.edu.

What Coding Agents Follow When Evolving Existing Code

should be preserved as requirements evolve. Coding agents must therefore reconcile past implementation decisions with the intent expressed in new task specifications.

Past Decisions vs. New Intent. Existing code records past implementation decisions. Every new change inherits decisions made in the past, but how does a coding agent determine which decisions to preserve, particularly when a new task expresses a different intent? This question raises two challenges in agentic software evolution.

First, the rationale behind past implementation decisions is often unavailable. Existing code reveals what previous developers chose, but rarely why [17, 38, 24]. For example, a repository may use an if-else chain rather than a dictionary lookup because of an earlier requirement or simply a developer's preference. Without this context, a coding agent cannot determine whether the existing code reflects a constraint that should be preserved.

Second, past implementation decisions may conflict with the new task intent. Different parts of a repository may follow different implementation patterns, while new task instructions may favor an alternative [30, 16]. For example, an agent adding an API endpoint may encounter existing handlers that serialize identifiers as integers, while the new task may specify a preference for string identifiers. Both options may satisfy functional requirements, but represent different implementation choices. The agent must determine whether to follow the existing precedent or the new instructions.

Despite substantial progress in evaluating coding agents in long-horizon software engineering tasks [13, 15, 40], how agents prioritize past implementation decisions and new task instructions remains poorly understood. In particular, we lack systematic evidence on the relative influence of agents' default preferences, implementation patterns in task-related code and elsewhere in the repository, and explicit task guidance.

Approach. We investigate how coding agents prioritize competing sources of guidance when modifying existing software repositories. We examine three factors: (1) agents' default implementation preferences, (2) repository precedent established by past implementations, and (3) explicit guidance in new task specifications. Our approach combines bidirectional controlled experiments in purpose-built repositories with a validation study in real-world open-source repositories.

We first establish agents' default preferences in a manually constructed Python/Flask repository. We design six implementation-choice cases that span naming, data representation, error handling, and control flow, each allowing two functionally correct alternatives, such as integer versus string identifiers. By removing relevant repository examples, we establish a baseline for two complementary controlled interventions:

  • Repository Precedent. We examine how historical implementations shift agents' default choices. We distinguish local precedent, established by existing endpoints for the resource being extended, from sibling-resource precedent, established by endpoints for other resources in the same repository. Holding task requirements fixed, we vary the number and placement of supporting examples and introduce conflicting patterns across resources. These interventions isolate how the prevalence and location of existing patterns influence agents' choices.

  • Explicit Task Guidance. We examine whether new instructions can override established precedent. Starting with code that favors one implementation, we compare four guidance conditions: no guidance, a written priority rule, a code example favoring the alternative, and both combined. We further test whether a rule reaches the agent equally well through the task description or through the harness's native instruction file. This reveals how different forms and channels of guidance redirect agents toward a new task intent.

Key Findings. Our study comprises 5,625 trials across six implementation pairs and four models: Claude Sonnet-4-6, Claude Opus-4-8, Codex gpt-5.6-sol, and Codex gpt-6-sol. We further evaluate four open-source repositories spanning Python, Go, and TypeScript: FastAPI RealWorld [20], FastAPI Clean Example [11], Go REST API [23], and ExpressJS API [14]. Three key findings emerge, highlighting the need to make implementation decisions and their intended priority explicit during software evolution.

First, repository precedent overturns agents' shared default choices in 359/360 trials. Without relevant repository precedents, all four agents favor the same implementation in each of the six pairs. Yet when all existing endpoints consistently use the opposite implementation, agents follow that precedent in 359/360 trials, despite unchanged functional requirements. In four open-source repositories, agents follow local precedent in all 945 functionally successful, classifiable error-handling implementations and 355 of 417 (85%) functionally successful response-envelope implementations.

Second, a single well-placed example can outweigh multiple examples elsewhere. With three supporting files, local precedents yield 96% adoption (347/360), compared with only 4% (13/360) for sibling-resource

What Coding Agents Follow When Evolving Existing Code

Figure

Figure 2: Illustrative Flask handlers for the motivating example. (a) An existing local handler serializes task IDs as numbers (line 6). (b) and (c) Two implementations of the new endpoint retrieve the same task with an identical query (lines 4–6) and differ only in how they serialize the identifier (line 8). (b) carries over the repository precedent (blue), whereas (c) follows a new instruction to serialize identifiers (orange).

precedents. Even within local code, changing file placement while holding the number of examples fixed can shift adoption from 0% to 100%. In one setting, a single well-placed example even outperforms two examples in other files. These findings show that the influence of repository precedent cannot be explained by example frequency alone.

Third, written priority rules override conflicting precedent more reliably than code examples alone (98% vs. 63%). When all existing endpoints favor the opposite implementation, written priority rules achieve both functional success and target adoption in 59/60 trials, compared with 38/60 for code examples alone and 0/60 without guidance. The effectiveness of written rules also extends to four open-source repositories, where a rule in the harness's native instruction file raises joint success from 0/120 to 117/120.

Figure 1 summarizes these findings. This paper makes three contributions:

  • We establish the prioritization of historical code and new task intent as a research problem in software evolution, introducing bidirectional controlled experiments to isolate their influence on coding agents.
  • We reveal that local precedent overrides default preferences and that where examples are placed can change adoption from 0% to 100% at a fixed example count.
  • We demonstrate that explicit rules override conflicting repository precedent more reliably than examples, motivating design-decision traceability to preserve implementation intent and priorities.

References (19)