Preface¶
Production-grade Agents typically start by relying on harness-engineering to manage the single-loop autonomy cycle: locking metrics, editable surfaces, logging, rollback, and human-review boundaries. But when failures recur, teams naturally think: “let the Agent modify its own prompts, workflows, even harness code based on failure modes.” The problem is: a loop will optimize whatever signal you hand it, including vulnerabilities in the signal itself; once evaluators, budgets, or sandbox boundaries fall on surfaces that can be rewritten, reward hacking and silent stagnation follow.
Below we introduce the open-source Skill self-improvement-loops: it comes from the Agent Skills for Context Engineering collection, published as the sixteenth Skill in CHANGELOG 2.4.0 (2026-07-08). The text advances the design question from “how to control a loop” to “how to let the loop rewrite itself within finite bounds without breaking the signals that guide it.”
What Is This¶
self-improvement-loops is a SKILL.md guidance document (Skill metadata version 1.0.0) for Agent platforms, maintained by the Agent Skills for Context Engineering Contributors.
One-sentence positioning: enable when the harness, scaffolding, workflow, or optimizer itself becomes the object of optimization—covering recursive self-improvement (RSI), meta-harness search, bounded self-editing driven by failure mining, scaffold-oriented evolutionary/population search, acceptance gating for self-modifying systems, and cases where “the mechanism that produces context” is versioned and evolved.
The division of labor with adjacent Skills is clearly stated in the frontmatter and body: single-loop governance without self-modification belongs to harness-engineering; evaluation and quality gates belong to evaluation; LLM-as-judge belongs to advanced-evaluation; remote sandboxes belong to hosted-agents; project initiation and cost estimation belong to project-development; self-editable context behavior belongs to self-managed-context.
Core Features¶
Optimization Ladder¶
The Skill uses a ladder table to summarize the depth of objects that published systems commonly optimize, and recommends: do not jump to a higher rung when a fix can be expressed at a lower one.
| Rung | Optimization Target | Example Systems in Text |
|---|---|---|
| 1 | Instruction prompt | Promptbreeder, GEPA |
| 2 | Structured context | ACE |
| 3 | Context mechanism | MCE |
| 4 | Workflow graph | ADAS, AFlow |
| 5 | Harness code | Self-Harness, Meta-Harness, Darwin Godel Machine |
| 6 | Optimizer code | STOP |
Outside-the-Loop Invariant¶
Evaluators, instrumentation, permissions, and budget enforcement must reside in a region the loop cannot modify. Operational points include:
- Budgets, permissions, and sandbox boundaries enforced by the runtime, not merely written into evolvable prompts.
- Expose scores and traces to the proposer; do not expose the scoring implementation source.
- OS/container-level sandboxing; detected exploits recorded as failure candidates, not high scores.
Empirical Acceptance Gating (Two Splits)¶
Acceptance of self-modifications should be based on measurement, not the proposer’s justification: use held-in (whether the weakness is fixed) and held-out (invisible to the proposer, checking for regression) splits; strict gating requires no regression on either side and strict improvement on at least one side, with repeated evaluation under randomized scoring. The text also provides an actionable Python example function accept(...).
Filesystem Experience Archive¶
Each candidate is saved as a directory containing source code, scores, and raw execution traces; proposers use grep-like tools to search the archive rather than stuffing historical summaries into context. The material emphasizes: ablation on raw traces outperforms scores or LLM summaries alone.
Failure-Driven Three-Stage Self-Editing¶
- Weakness mining: Cluster failure traces along three dimensions—verification-layer cause, behavioral causality, reusable mechanisms—and filter out “unaddressable” clusters.
- Bounded proposal: Input limited to editable surfaces, failure modes, pass-behaviors to preserve, and prior edit history; requires minimal changes, mutually distinct candidates, and audit notes.
- Verification and merge: Two-split gating; compatible edits merged, rejected items written to archive.
Additionally there is meta-level harness code search, context evolution (itemized delta, deterministic merge, context collapse prevention), diversity preservation (archive, offspring-discounts-parent selection, embedding dedup), Loop-Readiness Checklist, and Gotchas (prompt constraints evolved away, visible scorers gamed, monotonic rewrite collapse, etc.).
More detailed numerical values and incidents are in the same directory references/loop-design-evidence.md; in-text claim-* correspond to researcher/claims/index.jsonl.
Installation and Activation¶
This Skill follows the Agent Skills directory layout (subdirectory containing SKILL.md, optionally references/); do not compress into a single file to avoid breaking relative paths.
Full Package Installation (Recommended)¶
The repository is distributed as an Open Plugins plugin, with the manifest in .plugin/plugin.json and the Skill at repo root skills/.
Cursor:
- Install from Cursor Plugin Directory’s context-engineering entry, or clone the repo and point Cursor to the plugin root.
- Cursor reads
.plugin/plugin.jsonand discoversskills/.
Claude Code:
Add the marketplace and install the plugin in Claude Code (repo README example):
/plugin marketplace add muratcankoylan/Agent-Skills-for-Context-Engineering
/plugin install context-engineering@context-engineering-marketplace
Codex and other Open Plugins hosts: After installing the corresponding plugin, the host reads the same manifest to discover skills/.
Install Only self-improvement-loops¶
After cloning or downloading the repo, copy the entire skills/self-improvement-loops directory to the project-level Skill path (README examples use context-fundamentals for demonstration; replace the directory name):
# Cursor project
mkdir -p .cursor/skills
cp -R skills/self-improvement-loops .cursor/skills/
# Claude Code project
mkdir -p .claude/skills
cp -R skills/self-improvement-loops .claude/skills/
# Codex project
mkdir -p .codex/skills
cp -R skills/self-improvement-loops .codex/skills/
# Generic Agent Skills path (some Codex/OpenAI, Copilot CLI, etc. hosts)
mkdir -p .agents/skills
cp -R skills/self-improvement-loops .agents/skills/
Activation methods vary by host: full-package plugins are typically auto-activated by the router based on task description; after single-Skill copy, in clients supporting Agent Skills, when the task involves harness self-modification, meta-search, or acceptance gating design, the description in the frontmatter should trigger loading. Refer to each client’s documentation for specific UI.
Typical Usage¶
The Skill does not provide a standalone CLI; its value lies in design self-checks and archive layout. The three examples below come from the official SKILL.md.
Two-split acceptance gating (excerpt logic):
def accept(candidate, baseline, held_in, held_out, repeats=3):
d_in = mean_score(candidate, held_in, repeats) - mean_score(baseline, held_in, repeats)
d_out = mean_score(candidate, held_out, repeats) - mean_score(baseline, held_out, repeats)
if d_in < 0 or d_out < 0:
return False
return max(d_in, d_out) > 0
Held-out is invisible to the proposer; candidates sacrificing held-out for held-in should be rejected.
Experience archive directory structure:
search-run/
candidates/
c0041/
harness.py
scores.json
traces/
lineage.txt
frontier.json
rejected.jsonl
Proposers grep this tree as needed; by default do not pre-summarize the archive into prompts.
Route failures to the correct ladder rung (excerpt):
Observed: agent repeatedly uses a deprecated API despite instructions.
Wrong fix: propose a harness-code edit adding retry logic.
Right fix: rung 2. Inject current API docs into task context at
execution time.
Before implementing a self-improvement loop, you can first cross-check against the eight items of the Loop-Readiness Checklist (fast and automatable evaluation, held-out, runtime constraints, declared editable surfaces, lineage archive, staged evaluation cost, base capability threshold verification, human-review hooks).
Use Cases and Considerations¶
Suitable for:
- Designing Agents that propose modifications to harness, prompts, context playbooks, or workflows based on failure modes.
- Performing meta-search on harness/scaffold (meta-Agent, workflow graph tree search, program search with LLM mutation operators).
- Setting acceptance criteria for self-modifying systems or diagnosing regressions (reward hacking, diversity collapse, context collapse, false stability).
- Deciding which level—prompt, context, workflow, harness, or optimizer—should fix recurring failures.
Considerations:
- Recursive structures amplify base model quality: on weak models, mean scores may decline across iterations; perform fixed-iteration capability validation before enabling recursion, and track edit diffs to avoid “empty changes” disguised as convergence.
- Evaluation changes, expanding editable surfaces, promoting to production harness, etc., should be preserved as human decision points.
- Pair with
harness-engineering: the former defines the control plane, this Skill defines discipline after the control plane becomes an optimization target.
Conclusion¶
self-improvement-loops turns “can an Agent rewrite its own workflow” from a slogan into actionable constraints: optimization ladder, outside-the-loop evaluation, two-split gating, raw trace archive, and diversity mechanisms, with clear boundaries against other Context Engineering Skills.
Official directory: https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/self-improvement-loops