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

Keyan Guo, Rupam Patir, Hai-Peng Cai, Hong-Xin Hu

Published
Citations
1

TL;DR

The paper shows Codex, Claude Code and Qwen Code fix a vulnerability when shown a failing security test but often reintroduce the same class in a new session, and presents PRECEPT, which revises secure coding principles against each agent's own failures.

Read this as a

Why builders care

Editor's note

Writing a past fix into the agent's persistent context did not stop the same vulnerability class coming back, and generic secure coding guides were too broad to apply. Principles tuned to where the agent actually fails reached 97.1% secure working code on unseen task families.

How to apply it

Editor's note
  1. 1Test whether your coding agent repeats a security mistake in a fresh session; here agents reintroduced a fixed vulnerability class 26.7% of the time, about the same as agents that never saw it.
  2. 2Do not assume a note about a past fix in memory or rules files carries over; in this study the fix stayed tied to the task family it came from.
  3. 3Revise security guidance against your agent's own failing cases and keep a revision only if fresh runs show more secure code without a drop in functional success.

Code

Not found

No verified code link yet. We checked the abstract, arXiv comments and Hugging Face; if the authors release code later it will show up here.

Key results

From the abstract
  1. 1

    Across 14 task sequences, Codex, Claude Code, and Qwen Code fixed a vulnerability 85.7% of the time when shown the failing security test, then reintroduced the same vulnerability class in a new session 26.7% of the time, about as often as agents that had never seen it (27.5%).

  2. 2

    Neither recording the repair in the agent's persistent context nor supplying published secure coding principles closed the gap: the recorded fix stayed tied to the family of the task it came from, and the principles, written for human developers, remained too general to apply to the code at hand.

  3. 3
    97.1% secure working code

    On task families never seen during evolution, PRECEPT's weakest agent reaches 97.1% secure working code, above the strongest unaided agent at 81.9% and the strongest baseline at 87.7%.

  • AI coding agents increasingly write and submit code with limited human review, and much of it passes functional tests while remaining insecure.

  • We present PRECEPT, which 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, so that each principle comes to fire on the code where that agent actually goes wrong.
  • A revision is kept only if fresh executions show it makes code more secure while keeping functional success within a small tolerance of the agent without the library.

AI coding agents increasingly write and submit code with limited human review, and much of it passes functional tests while remaining insecure. We show that these failures persist. Across 14 task sequences, Codex, Claude Code, and Qwen Code fixed a vulnerability 85.7% of the time when shown the failing security test, then reintroduced the same vulnerability class in a new session 26.7% of the time, about as often as agents that had never seen it (27.5%). The capability is present; the retention is not. Neither recording the repair in the agent's persistent context nor supplying published secure coding principles closed the gap: the recorded fix stayed tied to the family of the task it came from, and the principles, written for human developers, remained too general to apply to the code at hand. The knowledge exists; it is not activated. We call the 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. We present PRECEPT, which 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, so that each principle comes to fire on the code where that agent actually goes wrong. A revision is kept only if fresh executions show it makes code more secure while keeping functional success within a small tolerance of the agent without the library. Improvement continues across evolution steps rather than saturating after the first. On task families never seen during evolution, PRECEPT's weakest agent reaches 97.1% secure working code, above the strongest unaided agent at 81.9% and the strongest baseline at 87.7%.

Everything on this page is written from this abstract. For methods and full results, read the paper PDF.

Ask the paper

Answers come from the paper summary and abstract.

Ask anything about “PRECEPT: Security Self-Improvement of Coding Agents via Evolving Principles”, or start with one of these:

Closest matches across the feed and every collection, by shared words in titles, topics and abstracts.