Recursive Self-Improvement Framework: How a 9B Model Drives Large Model Evolution
This article breaks down a practical recursive self-improvement (RSI) framework for AI agents, built on a simple division of labor: a small model (around 9B parameters) acts as the strategy proposer, while a large model handles implementation. It explains the three-layer architecture (a policy learning core, a skill and experience workspace, and an evaluation arena), how a shared search state makes decisions traceable, how online policy learning balances exploration and exploitation, and how conditional policy memory helps avoid the local patching loop. It also covers reusable skill assets, statistically sound evaluation, and engineering practices for building a cost-controlled, reproducible, and measurable continuous iteration loop.
1. Background: Why Large Models Get Stuck in Local Patching
In automated coding and AI agent development, recursive self-improvement (RSI) is a long-standing goal: a system should not only complete a task, but also learn from the outcome, adjust its next-round strategy, and get better over time. In practice, however, a counterintuitive pattern often appears: larger models do not necessarily keep making progress on coding tasks, and instead fall into a fixed mindset.
A typical example: the code fails, the model immediately locates the error and applies a patch; the patch still fails, so it tries another patch; the loop repeats, but all changes stay local to the originally chosen technical approach. The model rarely stops to ask a more fundamental question — whether the algorithm paradigm, data representation, or system structure chosen at the start is flawed in the first place. This path dependency artificially shrinks the search space and burns experiment budget in low-return regions.
By contrast, a small model of around 9B parameters is sometimes better at breaking out of the existing implementation and proposing an algorithm or architecture direction completely different from the current one. It does not carry the cognitive burden of complex code implementation and debugging, so it can focus on “where to go next.” This suggests a workable division of labor: the small model as strategy proposer, the large model as executor.
Based on this idea, this article abstracts a practical RSI framework design with three parts: an online policy learning core, a skill and experience workspace, and a competitive evaluation arena for testing whether learning actually happens. It also covers key engineering implementation points.
2. Overall Architecture: A Three-Layer Structure Separating Strategy from Execution
The framework is divided into three layers:
- Policy Learning Core: Maintains the shared search state and decides “which historical version to continue from, whether to explore or exploit, and which action to execute.” An online learning mechanism gradually makes these decisions more accurate.
- Skill and Experience Workspace: Distills reusable implementation snippets, tool wrappers, and debugging experience into searchable assets, so each round does not start from scratch.
- RSI Arena: Uses a unified benchmark and statistical methods to determine whether the system is genuinely learning, rather than showing an illusion caused by random fluctuation.
The three layers form a closed loop: the Core produces decisions → the executor produces code and experiment results → the Workspace distills experience → the Arena provides trustworthy feedback → the feedback flows back into the Core to update the policy.
A schematic control loop is shown below (pseudocode, structure only):
state = SharedSearchState(budget=200)while not state.exhausted():decision = core.select(state) # pick version + explore/exploit + choose actionresult = executor.run(decision) # large model writes code, debugs, testsstate.update(decision, result) # record evolution links and success/failureworkspace.distill(result) # distill reusable experienceif state.step % 20 == 0:arena.evaluate(state) # periodic trustworthy evaluation
3. Shared Search State: Making Decisions Evidence-Based
Policy learning requires observability. The framework maintains a continuously updated experiment record containing at least five types of information:
- Version lineage: Each produced code version and its parent-child evolution links, forming a search tree rather than a linear log.
- Result labels: Success, failure, or partial success, plus failure type (compilation error, failing tests, performance regression, etc.).
- Unexplored directions: Hypotheses that have been proposed but not yet validated, so good ideas are not forgotten.
- Budget constraints: Remaining experiment count, time, or compute quota, giving the policy cost awareness.
- Context summary: Task goal, constraints, and evaluation criteria, keeping semantics consistent across rounds.
With the lineage structure, choosing “which historical version to keep optimizing” becomes a node-value evaluation problem on a tree. With the budget field, exploration intensity can adjust dynamically based on remaining resources — more willing to try new paths when budget is ample, more inclined toward safe improvements when budget is tight.
4. Online Policy Learning: Balancing Exploitation and Exploration
4.1 Confidence-Bound-Based Policy Learning
The framework uses a KL-UCB-style method that estimates each candidate action’s value as “historical average return + uncertainty bonus.” Directions with high historical returns are reused first, while directions sampled fewer times with high variance get an extra boost, balancing exploitation and exploration. Compared with a purely greedy policy, this significantly reduces the probability of converging prematurely to a local optimum.
Two engineering points need attention: first, the reward definition should be robust — use a normalized composite metric (whether tests pass, magnitude of performance improvement, change in code complexity) rather than a single pass rate; second, apply confidence interval clipping to prevent individual outlier samples from skewing a direction’s value estimate.
4.2 Memory-Based Policy Learning
Remembering only that “a method succeeded once” is not enough; what truly transfers is conditional knowledge. The framework distills experience into Policy Memory, where each record contains: applicable condition, action suggestion, expected gain, and invalidation boundary. As new experiments are produced, memory entries are reinforced, revised, or eliminated after repeated falsification.
A schematic Policy Memory structure:
{"condition": "Task involves large-scale sparse retrieval with a strict latency budget","action": "Try approximate nearest neighbor + inverted index pruning first, rather than exact brute-force retrieval","expected_gain": "Lower latency with a slight, controllable recall loss","invalid_when": "Data scale is below hundreds of thousands or recall requirement is near-lossless"}
This kind of “experience with premises” resists overfitting better than bare conclusions and is easier for humans to review and intervene in.
4.3 Research Workflow: The Key to Breaking the Patching Loop
When the bottleneck comes from the approach itself rather than implementation details, continued patching yields very little. A dual-role workflow is therefore set up:
- Proposer: Analyzes the task definition, the existing execution harness, and historical experiment results, identifies capability gaps, and proposes new ideas orthogonal to the current route.
- Worker: Turns ideas into code, completes debugging and testing, and returns structured results.
The key is the “orthogonality constraint”: the Proposer is required to provide candidates methodologically different from the current main approach and explain the differences, mechanically countering path dependency. An idea quota is also set to guarantee at least one “change of route” attempt every few rounds.
5. Skill and Experience Workspace: Turning Success into Reusable Assets
The workspace accumulates three types of assets:
- Skill library: Encapsulates high-frequency, effective code patterns into callable units with signatures and preconditions, so the executor reuses them first instead of rewriting.
- Failure case library: Records typical errors and root causes as negative samples for later retrieval, reducing repeated mistakes.
- Evaluation and toolchain: A unified test entry point, log collection, and metric computation, ensuring results are comparable across rounds.
For retrieval, recall candidate skills by task semantic similarity, then rank them by budget and risk preference. Assets need versioning and lifecycle management: skills not hit for a long time are down-weighted, and skills with regression issues are quarantined immediately to prevent “experience pollution” from spreading to all subsequent rounds.
6. RSI Arena: Verifying Whether Evolution Is Real
The biggest trap in RSI is mistaking random fluctuation for capability improvement. The evaluation arena should:
- Fixed benchmark set: Cover different difficulty levels and domains, including problems that “can only be solved by changing route,” to test the real ability to break out of fixed patterns.
- Repetition and significance: Run the same configuration multiple times and use confidence intervals or significance tests to judge whether differences are credible.
- Process metrics: Beyond final pass rate, record average rounds to reach a solution, proportion of exploration actions, and repeated failure rate, characterizing “learning efficiency” rather than only the end value.
- Control baselines: Compare horizontally against baselines such as “local patching only,” “random policy,” and “large model alone,” quantifying the gain from the division-of-labor design.
7. Engineering Implementation Points and Common Pitfalls
- Reward design before algorithm tuning: If a metric has loopholes, a stronger policy will only exploit them faster.
- Compress the context budget: Lineage and memory grow quickly and need summarization and layered retrieval to avoid context bloat dragging down the executor.
- Isolation and rollback: Build and test each round’s output in an independent sandbox so abnormal versions can be rolled back quickly, protecting the mainline.
- Observability: Log decision rationale, actions, results, and metrics into a unified logging and alerting system for review; put experiment artifacts in object storage and delegate task scheduling to a container platform to form a reproducible pipeline.
- Human-in-the-loop gates: High-risk changes (involving data, permissions, cost) should have human confirmation points; automation does not mean running unattended.
There are three common pitfalls: letting the large model self-review only, without an independent evaluation standard; storing conclusions in memory without conditions, causing transfer failures; and setting no cap on the exploration budget, leading to runaway cost with little gain.
8. Conclusion
The value of “small model proposes strategy, large model writes implementation” lies not in replacing parameter scale, but in cognitive division of labor: decoupling divergent direction exploration from convergent engineering implementation, then constraining the loop with a shared search state, online policy learning, conditional experience memory, and trustworthy evaluation. For teams aiming to build automated R&D capabilities, this structure can map directly onto general capabilities such as container platforms, object storage, logging services, and monitoring and alerting on Baidu AI Cloud, forming a continuous iteration loop with controllable cost, reproducible results, and measurable effectiveness.
