PRECEPT: Security Self-Improvement of Coding Agents via Evolving Principles

arXiv:2611.33519 · cs.CR, cs.AI · Submitted 2026-11-24 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Security Radio. Generated commentary on the latest security and cryptography papers.

Nadia: I'm Nadia.

Elias: And I'm Elias, here with Priya.

Nadia: We're looking at the paper: "PRECEPT: Security Self-Improvement of Coding Agents via Evolving Principles".

Paper summary: Nadia: We’ve just been talking about how AI agents struggle to keep security fixes when they switch tasks, and the paper PRECEPT is trying to fix that by defining and implementing security self-improvement >

Elias: The main thesis is that we need an analogous ability for coding agents—the ability to learn from their own failures so those lessons stick across sessions and apply them everywhere >

Priya: So instead of just giving them a static set of rules, the paper proposes a learning procedure where the agent actively revises its knowledge based on what it breaks >

Nadia: It formalizes this with Definition one which outlines four conditions that a learning procedure needs to have to give an agent security self-improvement >

Elias: These four conditions are what define what we're looking for in a good learning procedure, focusing on how the agent learns from those failures >

Priya: They look at whether the lesson persists across sessions, whether it applies to new code, and crucially, if it manages to not break what already works >

Nadia: The authors test this by observing whether agents avoid vulnerabilities of the same type on later tasks when they use these evolved remedies compared to just using the original principles or no remedies at all >

Elias: They are asking themselves if recurrence is a failure of capability or just a failure of retention, which is a key research question they address >

Nadia: It’s about whether the knowledge exists in the system but isn't actually activated in practice when things get tricky or new >

Priya: This moves beyond just training the model or steering its decoding, it focuses on an internal mechanism for security knowledge that changes with what the agent gets wrong >

Elias: So, PRECEPT uses this idea of evolving principles to equip agents with that self-improvement ability through a structured loop of test analyze draft and decide >

Nadia: It’s a system where the agent tries a fix, tests it, analyzes why it failed for security reasons, drafts an improvement, and then decides whether to keep that revision or discard it >

Priya: And the decision to keep something is tied to functional code staying above a fixed floor while also showing that the fix actually helps >

Elias: So essentially they are building a feedback loop where security failures drive the refinement of the rules or principles themselves, rather than just relying on a single set of instructions >

Nadia: It really frames it as an internal mechanism for learning security, not just an external patch you apply to the model's training data >

Conclusion: Nadia: So to wrap up PRECEPT we’ve looked at how this framework aims to give coding agents a way to learn from their own security mistakes so that those lessons last >

Elias: The authors are showing that when you implement this security self-improvement, the agents show measurable improvements in code being both functional and secure compared to just using the original principles >

Priya: They’re demonstrating that this active learning procedure, where the agent revises its own knowledge based on failure and success, yields better results than what's possible with just persistent context or just a fixed set of published rules >

Nadia: The implications here are that we might need to design these agents not just as static tools but as systems capable of self-correction in security terms >

Elias: It’s about moving toward a system where the knowledge exists and is activated in a way that adapts to the specific code it's working on, which is what this paper calls security self-improvement >

Priya: But we have to remember the limitations they pointed out, like how security is judged by tests that only check for anticipated vulnerabilities >

Nadia: And then there’s the cost of evolution itself, since running these experiments requires executing main runs between thirty-five thousand six hundred and forty thousand times >

Elias: So it proves the capability is present but shows that retention isn't automatic, and we need this self-improvement mechanism to make it stick across different tasks >

University at Buffalo

cs.CR, cs.AI

Submitted: 2026-11-24

Updated: 2026-11-24

Comments: 19 pages, 3 figures, 14 tables

Code: https://github.com/ossf/python-secure-codingguide

License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/

Importance score: 86/100

The gist: AI coding agents increasingly write and submit code with limited human review, and much of it passes functional tests while remaining insecure.<ref:2611.33519#pg1,much of it passes functional tests…

Key concepts

Security Self-Improvement
This is the ability of an AI agent to learn from its own security mistakes. When an agent makes a mistake and a fix is applied, this learning procedure ensures that the lesson remains in its memory. This allows the agent to apply that specific lesson consistently across future coding sessions and new projects without forgetting what worked.
Vulnerability Recurrence
This refers to the failure of an agent to retain security knowledge. The study found that when a fix was applied, recurrence on a slightly different task dropped significantly, proving that simple context retention is not enough. True security self-improvement must ensure lessons persist even when the code changes.
PRECEPT Framework
PRECEPT is the system designed to give agents security self-improvement. It uses an evolving library of secure coding principles that are constantly revised based on the agent's own failures. This evolution happens through a cycle involving testing, analyzing, drafting solutions, and deciding whether to keep a revision.
Evolving Principles
This is the core mechanism of PRECEPT. Instead of using static security rules, the framework maintains a library of principles that are updated dynamically. These principles are revised when an agent fails on a task, ensuring that the knowledge base gets smarter and more resilient over time.

Terminology

Summary

AI coding agents increasingly write and submit code with limited human review, and much of it passes functional tests while remaining insecure. p. 0<ref:2611.33519#pg1,much of it passes functional tests while remaining insecure>. p. 0 We show that these failures persist. p. 0<ref:2611.33519#pg4>. The capability is present; the retention is not. p. 0<ref:2611.33519#pg4>. We call this missing ability security self-improvement: an agent learns from its own security failures so that each lesson persists across sessions, applies to new code, and does not break what works. p. 0<ref:2611.33519#pg4,We call this missing ability security self-improvement: an agent learns from its own security failures so that each lesson persists across sessions, applies to new code, and does not break what works>. p. 0

Vulnerability Recurrence Identification

The study identifies vulnerability recurrence as a failure of retention rather than capability.<ref:2611.33519#pg4,We call this vulnerability recurrence. p. 0 It is a failure of retention rather than of capability, because when the fix stayed in context, recurrence on a variant of the fixed task fell from 36. p. 07% to 13.9%>. This persistence is not achieved by persistent context or published principles alone. p. 0<ref:2611.33519#pg4>.

Security Self-Improvement Definition

The paper defines security self-improvement as a property of a learning procedure in which an agent learns from its own security failures so that each lesson persists across sessions, applies to new code, and does not break what works.<ref:2611.33519#pg4,We call it security self-improvement, in which a coding agent learns from its own security failures so that each lesson persists across sessions, applies to new code, and does not break what works>. p. 0 This learning procedure is formalized by Definition 1. p. 4<ref:2611.33519#pg5,Definition 1 (Security self-improvement). p. 4 A learning procedure L gives an agent security self-improvement if L and its sequence B0, B1,. p. 4.. meet four conditions>. p. 4

PRECEPT Design and Evolution

The PRECEPT framework equips coding agents with this ability through an evolving library that starts from authoritative secure coding principles and revises them against the agent’s own failures.<ref:2611.33519#pg4>. The evolution loop involves TEST, ANALYZE, DRAFT, and DECIDE steps. p. 4<ref:2611.33519#pg7>. The decision to keep a revision is based on whether fresh executions show that it helps while functional code stays above a fixed floor. p. 1<ref:2611.33519#pg4>.

Evaluation Results

PRECEPT significantly improves security outcomes across different metrics.<ref:2611.33519#pg4>. The evolved libraries raise the rate of code that is both functional and secure by 8. p. 19–11.6 percentage points over the agents on their own, 7. p. 10–8.1 points over the published principles, and 6. p. 19–9.7 points over each agent’s best learned baseline. p. 1<ref:2611.33519#pg4>.

Transferability and Generalization

The evolved libraries demonstrate transfer across agents and models.<ref:2611.33519#pg4>. Specifically, a library learned on Qwen3. p. 96 makes more of Mistral’s functional code secure than Mistral’s own (97. p. 83 against 91. p. 02%).<ref:2611.33519#pg12,Across models, we cap the Mistral run at 17 steps, so Table 9b compares the libraries each model had kept by step 17>. p. 8

Repository-Level Security

When applied to repository-level tasks from SusVibes, PRECEPT detects that securing repository code requires knowing the project.<ref:2611.33519#pg8>. The study suggests that for repository-level tasks, no library helped. p. 8<ref:2611.33519#pg8>.

Limitations

Limitations include the fact that security is judged by tests which only check anticipated vulnerabilities.<ref:2611.33519#pg8>. Furthermore, evolution is costly, with each main run executed 35,600 to 46,400 times. p. 2<ref:2611.33519#pg18>. The results also show that a library helps only in the language it was learned from (EQ5). p. 1<ref:2611.

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Security self-improvement capability: The improved system can learn from its own security failures so that each lesson persists across sessions, applies to new code, and does not break what works.

  2. PRECEPT mechanism: The system can evolve a library of principles from an agent’s own security failures through traceable mutation primitives, attributes each failure to the part of the library that failed, and keeps a revision only when fresh, paired executions show that it helps while functional code stays above a floor.

  3. Principle evolution: The system can revise published secure coding principles against its own failures, keeping a revision only if fresh executions show it makes code more secure while keeping functional success within a small tolerance of the agent without the library.

  4. Generalization of lessons: The system can generate revisions whose principles have the scope of a class of code, ensuring that a lesson drawn from one failure tends to fit only its task is avoided by revising principles to be applicable beyond an individual fix.

  5. Attribution and diagnosis: The system can assign each failed record a cause and the part of the library that failed, using causes like missing, unread, misapplied, or too strict to determine which primitives may fix it.

  6. Constrained search for improvements: The system can search for the best library Bstar by executing candidates and accepting them only if they meet an acceptance criterion, ensuring that a revision is accepted only when it meets one route and no rejection occurs.

  7. Traceability of changes: Every accepted revision is recorded and each primitive stamps its step in the provenance of what it changes, allowing each principle can be traced to its published source and to the revisions that changed it.

  8. Transfer of knowledge: The evolved libraries can transfer across agents and models, where they still significantly raise the share of functional code that is secure on other agents or models.

Sources

Related papers