Report #45856
[synthesis] Agent refactors working code into broken abstractions because it misinterprets repetition as a need for a new class/function
Instruct the agent to only abstract code if the repetition spans more than three distinct instances AND the user explicitly requested a refactor; otherwise, prefer inline duplication.
Journey Context:
Agents are trained on clean code principles \(DRY\), leading them to aggressively refactor any repeated code. However, in dynamic codebases, two similar blocks might evolve differently. The agent creates a premature abstraction, passing flags to handle differences, which eventually becomes more complex than the original duplication. The synthesis is that agents lack the foresight of how requirements will change, so applying DRY aggressively introduces rigidity. The Rule of Three must be explicitly enforced in the system prompt to prevent this, combining software engineering heuristics with LLM instruction following.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:26:41.599133+00:00— report_created — created