Don't Over-Engineer It: AI Coding Agents Write Too Much Code, and a Short Prompt Reduces It

Jay Desai, Fanyou Wu, Srinivasan H. SengameduarXiv 2026

TL;DR

AI coding agents frequently pass software engineering benchmarks while writing far more code than necessary—adding unrequested tests, docstrings, and refactoring that human developers still have to review. This paper formalizes that bloat as over-engineering and shows that a simple, three-sentence instruction in the system prompt cuts unnecessary code by 40% and reduces token usage for nearly every model tested, without hurting overall pass rates.

What Problem Does This Paper Address?

Imagine asking a developer to change a single default setting in Django—a two-line fix. An AI coding agent might return a 17-line patch: the two-line fix, plus an eight-line documentation rewrite and a seven-line unit test. Standard benchmarks like SWE-bench grade purely on pass/fail test execution, so both patches get a gold star. In practice, however, every extra line of code is a liability that someone has to read, review, and maintain.

The authors argue that over-engineering isn't just a harmless quirk; it's a systematic failure mode. They suspect it may stem from an RLHF "helpfulness bias": models trained on human preferences learn that thorough, comprehensive answers score higher in conversation, which translates into doing too much when the actual goal is the smallest possible surgical fix.

Methods

To measure bloat, the authors introduce the Over-Engineering Score (OES), which compares an agent's patch to the human-written reference ("gold") patch:

  • $\text{OES}_{\text{lines}}$: Total lines changed by the agent divided by lines changed in the gold patch. A score of 1.0 means the patch is the exact same size as the human fix.
  • $\text{OES}_{\text{scope}}$ vs. $\text{OES}_{\text{creep}}$: Splits the agent's edits into lines inside files the gold patch touched (scope) versus lines in other files (creep).
  • $\text{OES}_{\text{non-test}}$: Drops any agent edits made to test files, isolating production-code bloat.

To curb this behavior without retraining models or changing agent architectures, the authors test a lightweight system-prompt intervention. They prepend a three-sentence Critical Behavioral Constraint to the agent's prompt:

  1. Make the minimal change needed to solve the problem.
  2. Do not add tests, documentation, type annotations, error handling, or refactoring unless explicitly requested.
  3. Modify as few lines as possible while correctly resolving the issue.

Datasets

The authors first measure prevalence using 6,790 agent–task pairs from 14 public agents on SWE-bench Verified (500 Python tasks). For their controlled prompt experiments, they evaluate 14 models from 7 providers (including Claude, GPT, GLM, Mistral, Qwen, MiniMax, and DeepSeek) across three benchmarks:

  • SWE-bench Verified (500 Python tasks)
  • SWE-bench Multilingual (300 tasks across nine non-Python languages)
  • SWE-bench Pro (666 harder enterprise tasks)

They also run a targeted check on SWE-agent v1.1.0 (a shell-equipped scaffold) using Claude Sonnet 4.6 on Verified.

Key Insights and Ideas

  • The "Goldilocks Zone" of patch size: Across the 14 public agents, 11 had a median OES above 1.0 (ranging up to 8.20×). Plotting patch size against success reveals an inverted U: patches in the 1–1.5× range resolve at 59.6%, compared to just 34.8% for heavily over-engineered patches (>10×). This pattern holds even when controlling for task difficulty.
  • It's a focus constraint, not a brevity constraint: The prompt doesn't primarily make agents write shorter code inside the right files. Instead, 81% of the OES drop comes from eliminating creep—stopping agents from wandering into files the human fix never touched.
  • Unrequested tests are the main culprit: Nearly 79% of the extra files agents touch at baseline are test files. When test files are excluded, the prompt's OES reduction drops from 40% to 14%.
  • Prohibition beats vagueness: In a sentence-ablation study, explicitly forbidding unrequested additions ("Do not add tests, documentation...") proved much more effective than simply asking for a "minimal" change.

Key Results

On SWE-bench Verified, the minimality prompt reduces mean $\text{OES}_{\text{lines}}$ by 40% across 14 models (with 13 of 14 models shrinking, and a median per-model reduction of 43%). It also cuts input tokens per task for 13 of 14 models—by up to 42% for GPT-5.4 and 29% for Sonnet 4.6.

Figure 1: Per-model effect of the minimality constraint on SWE-bench Verified (C0 →C1; dashed line = reference size). (a) Mean OESlines. (b) The same with test-file lines removed. (c) Input tokens per resolved task (log scale). Models are sorted by baseline OES.

Importantly, aggregate resolution rates do not change significantly (+0.6 percentage points on Verified, −0.3 pp on Multilingual, +0.4 pp on Pro). However, individual models react differently:

  • Claude Sonnet 4.6 significantly improved (+6.4 pp on Verified, and jumped from 50.0% to 62.6% in the SWE-agent scaffold).
  • OpenAI-trained models (particularly GPT-5.4 at −7.6 pp) regressed, as the constraint occasionally pushed them into writing too-small patches or submitting no patch at all.

Limitations and Future Work

  • Reference-dependent: OES requires an expert-written reference patch, meaning it measures distance from one accepted human fix rather than absolute code quality or maintainability.
  • Scaffold simplicity: The main experiments used a simple six-tool, no-shell agent with a 20-call budget; production agents with shell access and test runners may behave differently.
  • Per-model tuning needed: Because the prompt can cause certain models to under-edit or bail out, teams should A/B test it per model rather than deploying it blindly.
  • Testing the RLHF hypothesis: Confirming whether RLHF helpfulness bias truly drives over-engineering will require comparing matched base and instruction-tuned checkpoints of the same model.

Summary updated

BibTeX
@misc{desai2026don,
  author = {Jay Desai and Fanyou Wu and Srinivasan H. Sengamedu},
  title = {{Don't Over-Engineer It: AI Coding Agents Write Too Much Code, and a Short Prompt Reduces It}},
  year = {2026},
  eprint = {2612.04613},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2612.04613},
}
Figure