SelfOp: An Optimization Algorithm for Self-Improving Security Agents
Organizations: ECE Department Boston University · CS Department UC Santa Barbara
Abstract
LLM agents are increasingly used for security tasks: vulnerability discovery, exploit reproduction, and patch generation. Improving them at the model level demands expert demonstrations or computable rewards, which security tasks rarely offer: traces are costly, failures hard to diagnose, rewards sparse, and non-computable. Efforts thus shift to the harness and context, but manual tuning needs task-specific expertise and scales poorly, while automated methods rely on scarce ground truth, stronger optimizer models, or unguided propose-and-evaluate loops that reduce to costly trial and error. We introduce SelfOp, an algorithm that automatically improves a frozen security agent's task context (instructions, skills, and reference documents), without modifying its execution harness and model weights. SelfOp casts context optimization as chain-rule-inspired textual gradient descent: from a single instance's outcome, it propagates error signals backward through the evaluator, the agent's trajectory, and the context artifacts that shaped its behavior, yielding per-instance textual gradients. Gradients are accumulated across instances by clustering, ranking, and filtering, and committed only under cross-instance consensus. A convergence detector monitors the gradient signal itself and stops once the context has absorbed the generalizable information in the training data, without held-out validation data. We evaluate SelfOp on CyberGym, a benchmark of real-world vulnerability reproduction tasks. With fewer than 200 training examples, SelfOp yields a 17-point self-improvement for GPT-5.4-mini (with Codex), enough to surpass the frontier GPT-5.4 baseline by 6 points, and an 18.5-point self-improvement for GPT-5.4 itself. The optimized skills also transfer across models, highlighting that SelfOp-optimized skills learn generalizable task knowledge not model-specific patterns.
Figures & tables
| Method | Param | Grad | Accum | Conv | Meta |
|---|---|---|---|---|---|
| TextGrad [ 17 ] | graph var/prompt | ✓ | – | – | – |
| GEPA [ 39 ] | prompt | – | – | – | – |
| ACE [ 15 ] | text playbook | (✓) | ✓ | – | (✓) |
| MCE [ 16 ] | skills (context) | – | (✓) | – | – |
| CoEvoSkills [ 37 ] | skill package | – | – | – | (✓) |
| Meta-Harness [ 18 ] | harness code | – | – | – | – |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Step | Ref. | What the step added |
|---|---|---|
| 0 | 0 | CyberGym base prompt, i.e., a task statement plus a submit.sh command |
| 1 | 4 | Rewrites the seed as an operating procedure of six sections; externalizes startup, validation, delegation, and payload heuristics |
| 2 | 6 | environment-sanity , hypothesis-discipline : one live hypothesis at a time |
| 3 | 7 | bug-family-diagnostics ; submit.sh becomes the sole source of truth |
| 4 | 7 | Pre-submit gate : four conditions that must hold before submission |
| 5 | 7 | Proof ladder : diagnostic / provisional / proven ; only proven may be submitted |
LLM Agent Self-Improvement
Large language model agent self-improvement studies how agents use experience and feedback to improve their behavior, tools, and workflows.
See all 277 papers