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

> PRECEPT evolves scoped secure-coding principles from agents' security failures, testing changes with fresh paired runs and a pass@1 floor. On held-out SeCodePLT families, 97.1–98.5% of functional code passed security tests; new-session recurrence fell from 26.7% to 11.5%.

- arXiv: https://arxiv.org/abs/2611.33519
- Authors: Keyan Guo, Rupam Patir, Haipeng Cai, Hongxin Hu
- Published: 2026-11-27
- Topic: Agents
- Visual carousel: https://instaxiv.com/p/2611.33519
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## Can coding agents remember a security fix?

**11.5%** With PRECEPT; fix alone: 26.7% recurrence

## They could fix a flaw, then repeat it

**Shown failing tests:** In 14 held-out SeCodePLT chains, Codex, Claude Code, and Qwen Code (Qwen3.6) fixed 85.7% of flaws after seeing security-test failures.

**New session, same flaw class:** Recurrence on later same-class tasks was 26.7%, versus 27.5% without an earlier fix; the difference was not clear.

## General advice worked only after it got specific

**Published OWASP rules:** All 218 rules (24.2%) and CWE-relevant rules (23.3%) barely changed recurrence from 27.5%; neither reduction was measurable.

**Handwritten class-level rule:** A rule restated for a code class lowered recurrence to 16.7%. Task-specific guidance reached 6.9%, but had to be written per task.

## A redirect rule shows what evolving principles add

![Figure 2](https://cdn.instaxiv.com/figures/2611.33519/figure2.webp)

PRECEPT adds a code situation, required check, and allowed behavior to published advice. Dashed boxes trace a redirect rule; gray boxes show code on one held-out task, where its check misses //evil.com. (Figure 2)

## PRECEPT turns failures into auditable library changes

1. **Test**: Run the current agent on training tasks; record documents opened, edits, diffs, and failed tests.
2. **Analyze**: Diagnose failures as missing, unread, misapplied, or too strict; each cause points to a different repair.
3. **Draft**: Make named, traceable edits into class-level rules without training-task details.
4. **Decide**: Fresh paired runs test revisions; a ledger pools inconclusive evidence. Validation selects a library; clear >3-point pass@1 losses against the unmodified agent trigger rejection.

## The lesson persisted after the repair

| Method | Recurrence (%) |
| --- | --- |
| No earlier fix | 27.5 |
| Fix alone | 26.7 |
| Own note | 15.0 |
| **PRECEPT (−3.5 pp vs note)** | **11.5** |

_Later-task recurrence in new sessions: 36/42 successful-fix pairs, 14 held-out chains; library given only at later task (EQ1a)._

## More working outputs passed security than under baselines

| Method | Codex S|P (%) | Claude S|P (%) | Qwen Code S|P (%) |
| --- | --- | --- | --- |
| Best baseline per agent | 84.9 | 87.7 | 86.7 |
| **PRECEPT (↑9.4–13.6 pp)** | **98.5** | **97.1** | **97.8** |

_S|P = share of functional outputs passing security; best baseline per agent. SeCodePLT test: 129 tasks from held-out families (EQ2)._

## Security was not bought by breaking functionality

| Method | Codex pass@1 (%) | Claude pass@1 (%) | Qwen Code pass@1 (%) |
| --- | --- | --- | --- |
| No guidance | 51.3 | 46.3 | 45.0 |
| **PRECEPT** | **51.4** | **49.8** | **48.9** |

_pass@1 = functional success; ten executions per SeCodePLT test task. Floor: 3 points below the unmodified agent (EQ2)._

## The search kept improving after its first win

![Figure 3](https://cdn.instaxiv.com/figures/2611.33519/figure3.webp)

Each plotted point is a kept library's secure-pass@1, requiring functional and security passes. Validation gains were slower and varied; one-quarter to two-thirds came after the first keep. (Figure 3)

## Rules traveled across agents, less evenly across models

**Across agent scaffolds:** On SeCodePLT, libraries learned by the three Qwen3.6 agent scaffolds yielded 96.5–98.2% S|P across them; pass@1 stayed within the 3-point floor.

**Cross-model transfer:** Qwen3.6's library raised Mistral's S|P from 81.9% to 97.3%; Mistral's library gave Qwen3.6 86.5%, not significantly above the 85.5% seed. On CWEval, pass@1 fell beyond the floor in C, C++, and JavaScript.

Transfer crossed scaffolds, but model and language still mattered.

## What the evidence does not settle

- **Security is test-defined**: Benchmarks cover anticipated attacks; passing them cannot establish security against vulnerabilities their tests never exercise.
- **Repositories remain open**: On SusVibes, no library significantly beat no guidance; project knowledge and getting rules to later edits remain unresolved.
- **Runs are costly and narrow**: Main results use one Qwen3.6 run per agent; each used 35,600–46,400 executions and 0.25–0.30M deployment input tokens per execution, versus 0.11–0.16M without guidance.

Best used when: Best supported for test-rich function tasks with repeated failures per vulnerability class.

## Key takeaways

- A repair is not a lesson until it persists across sessions and applies to unseen code.
- For test-rich function tasks, evolve scoped principles and gate changes with paired evidence and a functionality floor.
- Can project-specific rules reach the edits that need them in long repository tasks?

## Links

- arXiv: https://arxiv.org/abs/2611.33519
- PDF: https://arxiv.org/pdf/2611.33519

## Citation

```bibtex
@article{guo2026precept,
  title   = {PRECEPT: Security Self-Improvement of Coding Agents via Evolving Principles},
  author  = {Guo, Keyan and Patir, Rupam and Cai, Haipeng and Hu, Hongxin},
  journal = {arXiv preprint arXiv:2611.33519},
  year    = {2026},
  url     = {https://arxiv.org/abs/2611.33519}
}
```
