Researchers cut coding agents’ excess code with a short prompt
In an experiment by Amazon researchers, a three-sentence instruction opening the system prompt reduced agents’ code changes for 13 of 14 models. The overall share of resolved tasks did not change significantly.
Amazon researchers Jay Desai, Fanyou Wu and Srinivasan H. Sengamedu published their study on arXiv on 2 December. The paper is a preprint and has been accepted for a workshop at the AAAI-27 conference.
In one example from the study, the human fix changed two lines of a Django setting. GPT-5.4 returned a 17-line patch: it had rewritten the documentation and added a new unit test. With the prompt, the same model changed exactly the same two lines. Both versions passed the tests.
The researchers measure over-engineering with the Over-Engineering Score (OES), which compares the number of lines in an agent’s change with the number in the human reference fix. Across 6,790 solutions from 14 public agents, the median ranged from 0.67 to 8.20, depending on the agent. Changes of 1–1.5 times the size of the reference fix resolved the task most often (59.6 per cent). Of changes more than ten times larger, 34.8 per cent resolved it. The authors say this is an observed association, not proof that extra code causes failure.
The researchers added the prompt to the start of the agent’s system prompt. Framed as a critical operating constraint, it tells the agent to make the minimal change needed to solve the issue, not to add tests, documentation, type annotations, error handling or refactoring unless explicitly asked, and to change as few lines as possible while still solving the issue correctly.
The researchers tested the prompt with 14 models on the 500 tasks of the SWE-bench Verified benchmark, in which an agent fixes a bug in a Python project from an issue report. Mean OES fell for 13 of the 14 models. Most of the reduction did not come from the files the human fix changed: the agents edited other files far less often. Without the prompt, the models edited 1,544 such files in total, 79 per cent of them test files. Excluding test files, changes shrank by 14 per cent on average rather than 40 per cent.
Smaller changes did not mean more resolved tasks. The table shows mean OES for selected models without and with the prompt, and the change in resolved tasks.
| Model | OES without prompt | OES with prompt | Resolved, change |
|---|---|---|---|
| Claude Sonnet 4.6 | 2.32 | 1.11 | +6.4 pp |
| Claude Opus 4.6 | 1.62 | 0.99 | +2.4 pp |
| DeepSeek V3.2 | 1.19 | 1.25 | +3.8 pp |
| GPT-OSS 120B | 1.74 | 1.28 | −4.6 pp |
| GPT-5.4 | 2.88 | 0.82 | −7.6 pp |
Source: Desai et al., SWE-bench Verified, 500 tasks, one run per model and condition. The authors say changes of about two percentage points are within run-to-run variation.
Across all models, the combined change was +0.6 percentage points, which is not statistically significant. After correction for multiple comparisons, GPT-5.4’s decline and Sonnet 4.6’s improvement remained significant. On SWE-bench Multilingual and Pro, OES also fell for all models, and the resolution rate did not change significantly. On Pro, changes were already smaller than the reference fix, so the prompt mainly made them smaller still. With the prompt, OpenAI’s models more often left a task with no changes at all. The authors therefore recommend testing the prompt for each model and use case rather than making it a default everywhere. Input tokens per task fell for 13 of 14 models, by up to 42 per cent.
The researchers deliberately used a simple harness, the program that gives the model its tools and runs its steps. It had six tools and no command line, and allowed at most 20 tool calls (40 on SWE-bench Multilingual). As a result, resolution rates are lower than leaderboard figures. In the SWE-agent harness, with a command line and up to 150 tool calls, Sonnet 4.6’s resolution rate rose with the prompt from 50.0 per cent to 62.6 per cent, mainly because it returned fewer empty patches. The authors do not generalise from this single-model result.
OES measures distance from the reference fix, not whether the code is needed. No human review assessed whether the fixes would be accepted. The authors say the effect must be tested separately on tasks other than bug fixes.
Read more: How an agent works · Agent map