Published
- 5 min read
By Allan D - Editor, AI Security Wire
Coding Agents Fix a Bug, Then Write It Again: What the PRECEPT Preprint Found
A coding agent that has just been told its code is vulnerable will usually fix it. Give it a similar task in the next session and it will often write the same flaw again. That is the finding behind a new preprint from the University at Buffalo, and it matters for anyone letting agents open pull requests with little review.
The paper, “PRECEPT: Security Self-Improvement of Coding Agents via Evolving Principles” (arXiv 2611.33519, submitted 24 November 2026), is by Keyan Guo, Rupam Patir, Haipeng Cai and Hongxin Hu. It is an arXiv preprint, and we found no peer-reviewed version as of 27 November 2026.
The recurrence result
The authors built 14 task sequences from SeCodePLT, a Python secure-coding benchmark, covering 12 of its 17 weakness classes. In each sequence an agent writes code that passes functional tests but fails the security tests. It is shown the failing tests, with no vulnerability named, and asked to repair its work. Later it meets a task with the same CWE.
Across Codex, Claude Code and Qwen Code, the agents fixed the flaw 85.7% of the time. In a fresh session they then reintroduced the same CWE in 26.7% of executions. Agents with no earlier fix did so 27.5% of the time. The authors’ reading is that the capability is present and the retention is not.
One caveat belongs next to those numbers. All three scaffolds ran on the same open model, Qwen3.6-35B-A3B, with a 100-turn budget per execution. The results describe those scaffolds on that model.
Why the obvious remedies fell short
The study tested the two fixes most teams would reach for first.
Persistent context. With memory features on, no agent recorded the fix by itself, and none of the 36 later sessions held a trace of it. When the agents were asked to write a note, they did so in 28 of 36 cases. Those notes cut recurrence on a variant of the same task family, from 36.7% to 13.9%. They did little for other families of the same CWE. Of the 28 notes, 13 tied the lesson to the fixed task’s own functions or fields.
Published principles. The OWASP Secure Coding Practices directly address the weakness in 19 of the 27 later tasks by one model rater (Claude). A second rater (GPT) counted 17 of 27, and they agreed on 25. Supplying all 218 principles gave 24.2% recurrence and supplying only the relevant ones, which the authors selected by hand as an oracle, gave 23.3%, against a 27.5% baseline. Neither gain was statistically distinguishable from zero. Restating the relevant principle for the class of code, again by hand, cut it to 16.7%, which was a measurable gain. The knowledge was there, but in its general form it did not turn into the right check.
What PRECEPT does
PRECEPT keeps a library of principles that the agent reads on every task. It starts from published guidance and changes only through a fixed set of edit operations, so each principle traces back to its source. After running the agent on training tasks, it attributes each failure to the principle that failed, drafts a revision for a class of code, and keeps the revision only if fresh paired executions show better security while functional success stays within a set tolerance. Acceptance rests on execution results, not on a model’s opinion.
On held-out task families, the authors report:
- 97.1% to 98.5% of the code that passed functional tests was also secure (not of all output), against 79.7% to 81.9% for the agents unaided. The strongest baseline method reached 87.7%.
- Recurrence in new sessions fell from 26.7% to 11.5%, against 15.0% when agents carried forward their own notes.
- Libraries learned on one agent also raised secure output on other agents and models, though a library helped only in the language it was learned from.
Where it does not work yet
The authors are direct about limits. On 184 Python feature tasks from 101 real projects (SusVibes), no library made Codex’s code significantly more secure. Only 10.5% to 13.5% of functional code was secure, against 81.3% to 98.5% on SeCodePLT. They point to three causes: securing project code requires project-specific knowledge, lessons from one project rarely transfer, and the guidance made up only 0.11% of input tokens in long repository runs. In the Jinja example they cite (CVE-2024-22195, an HTML attribute injection scored 6.1 by NVD and fixed in Jinja 3.1.3; not in CISA KEV as of feed 2026.11.25), the agent escaped attribute values correctly but missed that an attribute key containing a space was the actual hole.
Other limits: security is judged only by each benchmark’s anticipated tests, each agent had a single evolution run, and each run executed the agent 35,600 to 46,400 times. Executions with the final library also read 0.25 to 0.30M input tokens, against 0.11 to 0.16M without guidance. All figures are the authors’ own and unreplicated.
What this means for defenders
Our assessment: do not assume an agent that fixed a bug last week will avoid it this week. A fix applied in conversation is not a lesson the agent keeps.
- Keep security tests in CI as the gate, and add a regression test for every weakness class an agent has been caught writing, so the next recurrence fails the build.
- Put class-level secure coding rules in the repository instructions file, written as “where this applies, what must hold” rather than “what we fixed in ticket 412”. The paper’s data favor class-specific wording over general lists.
- Do not count a long OWASP checklist in a prompt as a control.
- Keep human review for agent-authored changes in security-relevant code until you have measured your own recurrence rate.
The paper also covers attacks on the learning loop itself, such as planting text in test inputs that the analysis reads. Those are discussed, not measured. Teams that adopt evolving rule libraries should treat the library as a security-sensitive artifact with review and provenance.
References
- Guo, K., Patir, R., Cai, H. and Hu, H., “PRECEPT: Security Self-Improvement of Coding Agents via Evolving Principles”, arXiv 2611.33519: https://arxiv.org/abs/2611.33519
- OWASP Secure Coding Practices, quick reference guide: https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/
- MITRE Common Weakness Enumeration: https://cwe.mitre.org/
- NVD record for CVE-2024-22195 (Jinja): https://nvd.nist.gov/vuln/detail/CVE-2024-22195
Frequently Asked Questions
- What is vulnerability recurrence?
- It is the term the PRECEPT authors use for a coding agent reintroducing a weakness class (a CWE) it has already fixed. In their 14 test sequences, agents fixed the flaw 85.7% of the time when shown the failing security test, then wrote the same CWE again in a new session in 26.7% of executions. Agents that had never seen the flaw did so 27.5% of the time.
- Does PRECEPT fix the problem for real repositories?
- Not in this paper. On 184 Python feature tasks from 101 real projects (the SusVibes benchmark), no library, including the one PRECEPT evolved on those tasks, made Codex's code significantly more secure than no guidance. Only 10.5% to 13.5% of its functional code was secure. The authors outline future work for it.
- Were these results measured on Claude or GPT models?
- No. Codex, Claude Code and Qwen Code are scaffolds, and in this study all three ran on the same open model, Qwen3.6-35B-A3B. The headline numbers describe those scaffolds on that model, so they should not be read as measurements of Anthropic or OpenAI models.