{
  "id": 15001891,
  "title": "The agent created a new file instead of editing the existing one. Now there are two.",
  "url": "https://urgent.news/2026/10/16/the-agent-created-a-new-file-instead-of-editing-the-existing-one-now",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-16T17:26:02.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/jeff_pdc/the-agent-created-a-new-file-instead-of-editing-the-existing-one-now-there-are-two-35m4"
  },
  "original_language": "en",
  "account": "The agent generated a new file instead of modifying an existing one, resulting in two validator files. The first reason for this behavior is the shallow search capability of the agent, which only scans the root directory and common locations like src/ for existing functions. The second reason is that creating a new file requires less effort compared to editing an existing one, as it doesn't involve searching for the function, adapting to different styles, or managing compatibility issues. Additionally, the task given to the agent didn't instruct it to verify if the required functionality already existed. The consequence of this issue is worse than creating a file in the wrong location, as it leads to duplicated functionality, which may go unnoticed until a bug is encountered in one of the validators. Over time, this accumulates, leading to a growing number of duplicate files in different directories. To prevent this problem, it is advised to instruct the agent to search the codebase for similar existing functions before writing any new shared utility. A simple grep search for relevant keywords across the codebase can help the agent identify if the functionality already exists. Furthermore, specifying the expected location of the new utility file can eliminate ambiguity and prevent the creation of parallel files. Ultimately, the main issue lies in the fact that agents are primarily designed to generate code, rather than adapting to existing systems. To address this, agents need to be prompted to consider where the new file should be placed and whether it already exists, as humans naturally would do.",
  "summary": "The PR diff looks fine. You asked the agent to add a phone-number validator. It added a file called validation-helpers.ts with a clean, well-tested validatePhone() function. CI is green. The code is correct. It is also wrong. Because utils/validators.ts already exists. It has been there for two years. It already exports validateEmail() , validatePostalCode() , and a dozen other validators. The…",
  "key_points": [
    "Agent created new file instead of editing existing one",
    "Two validator files now exist due to agent's behavior",
    "Duplicate functionality may cause unnoticed bugs"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}