Recursive Self-Improvement: An Evolution Paradigm Driven by Small Models

    This article explains how to engineer Recursive Self-Improvement (RSI) so that an AI agent improves its strategy, not just its code. It covers a three-part architecture—decision kernel, workspace, and arena—and details shared search state, UCB-based and memory-based strategy learning, and a proposer-executor workflow. It also outlines evaluation practices, common failure modes, and practical deployment advice, showing how a small model can steer a larger model toward continuous improvement.

    1. Background: Why “Being Able to Write Code” Is Not “Being Able to Do Research”

    When an agent is asked to complete programming tasks autonomously, a recurring pattern appears: the model is strong at generating and debugging code but lacks the instinct to “take a different path.” When a program errors, it adds a branch; when a test fails, it adds a retry layer. Patches pile up until the result runs but is structurally fragile and mediocre in performance. The essence of this behavior is local search within a fixed solution space, with no re-partitioning of the solution space itself.

    Recursive Self-Improvement (RSI) is concerned with exactly the latter: whether a system can distill reusable strategies from the feedback of each task run and use those new strategies to change how the next round searches, forming a positive feedback loop of “getting better at running with every run.” To engineer this, three problems must be solved at once: where decisions come from, where experience is stored, and how progress is measured.

    A counterintuitive but sound engineering choice is to not let the strongest code model double as the strategy decision-maker. Larger models have clear advantages at the syntax and implementation level, but their output distribution is more concentrated on “common fixes,” which tends to reinforce existing paths. A small model on the order of about 9B, by contrast, offers higher sampling diversity and lower per-inference cost, making it better suited to high-frequency, exploratory strategy proposals. This yields a clean division of labor: the small model proposes strategies, the large model writes the implementation.

    2. Overall Architecture: Three Separable Responsibility Domains

    A practical RSI framework is typically split into three parts, decoupled through explicit data contracts:

    • Decision kernel: maintains the global search state and handles online strategy learning and solution selection;
    • Workspace: handles persistence and version management of skills, patches, and experiential knowledge;
    • Arena: handles standardized evaluation and determines whether the system is truly benefiting from the task.

    The benefit of this split is replaceability: swapping the implementation model does not affect the strategy layer, and changing the evaluation set does not affect the experience layer, so teams can evolve each part independently.

    3. Decision Kernel: Turning “What to Do Next” into a Computable Problem

    3.1 Shared Search State

    The kernel maintains a continuously updated experiment record containing at least: historical code versions and their lineage (which version was derived from which), the metrics and failure reasons of each run, directions not yet explored, and the remaining budget. More formally, it can be viewed as a labeled directed graph plus a statistics table:

    1. # Illustrative data structure, not the interface of any specific product
    2. state = {
    3. "nodes": {vid: {"code": str, "parent": vid, "score": float, "tags": [...]}},
    4. "frontier": [vid, ...], # candidates to keep optimizing
    5. "budget": {"iterations": 200, "compute_hours": 12},
    6. "stats": {(strategy_id, context): {"n": 10, "mean": 0.62, "var": 0.03}},
    7. }

    With this record, “which version to continue from” and “explore or exploit” turn from intuitive judgment into an optimizable decision problem.

    3.2 UCB-Based Strategy Learning

    A KL-UCB-style method can be used so that strategy selection considers both historical average reward and current uncertainty: directions with few samples get an exploration bonus, while directions repeatedly proven ineffective get a penalty. Compared with pure greedy selection, this significantly suppresses the tendency to “converge prematurely onto a patching routine.” Two engineering points matter: first, rewards should be normalized to avoid scale differences across evaluation dimensions contaminating comparisons; second, contexts should be discretized to a statistically meaningful granularity, otherwise the statistics become too sparse and confidence intervals lose meaning.

    3.3 Memory-Based Strategy Learning

    Effective experience is distilled into strategy memory. An entry records not only “success/failure” but also the applicable conditions and concrete guidance, for example, “when the input size exceeds a certain threshold and the current implementation is a nested double loop, prefer trying divide-and-conquer or cache reuse.” Memory needs lifecycle management: it can be reinforced by new evidence, revised, or retired after a distribution shift. A practical approach is to maintain a support count and a counterexample count for each memory entry, down-weighting it once it falls below a threshold.

    3.4 A Proposer–Executor Workflow with Separation of Concerns

    When the bottleneck comes from the method itself rather than implementation details, patching alone cannot break through. This calls for two-role collaboration: a proposer analyzes the task, the existing scaffolding, and historical results to locate capability gaps and offer new ideas; an executor implements, debugs, verifies, and returns structured results. The key is interface constraints—the proposer outputs only verifiable hypotheses and expected metrics, and the executor returns only metrics and failure summaries, so the context is not flooded with lengthy logs.

    4. Workspace: Turning Experience from “Logs” into “Assets”

    The workspace handles version management of three kinds of objects: reusable skills (verified code snippets and invocation patterns), task context (constraints, evaluation criteria, data slice descriptions), and strategy memory. Practical points include:

    • Make all artifacts content-addressed to guarantee traceability and deduplication;
    • Require skills to pass a unified evaluation gate before entering the library, avoiding “accidentally passing” samples polluting the experience pool;
    • Attach applicability-domain tags to experience, and filter by domain before similarity ranking at retrieval time to reduce cross-domain misuse;
    • Keep failure samples, as they are an important source of negative strategies.

    5. Evaluation: How to Prove “Real Evolution”

    Evaluation is the part of RSI most easily overstated. A credible metric should satisfy: the task distribution is fixed and not spied on by the training process; what is reported is the trend as iterations progress rather than a single best point; and it distinguishes “best single-run score” from “average capability improvement.” It is advisable to observe three kinds of metrics at once: task success rate, the budget needed to reach an equivalent score (sample efficiency), and strategy diversity (avoiding degeneration into a single routine). If average capability rises while strategy entropy keeps falling, the system is overfitting the current evaluation set and needs exploration pressure or an expanded task distribution.

    6. Common Failure Modes and How to Avoid Them

    • Reward leakage: evaluation information indirectly enters the context via logs or file names, causing inflated scores;
    • Memory ossification: old experience keeps being selected under a new distribution, requiring a forced exploration quota;
    • Context bloat: long histories compress the judgment of the strategy layer, so hierarchical summarization should be applied;
    • Budget overrun: set a hard cap and early-stopping rule for each candidate;
    • Non-reproducibility: fix random seeds, containerize the runtime environment, and retain complete lineage.

    7. Deployment Recommendations

    To build similar capabilities in your own environment, start from a narrow task domain, use a container platform for isolated execution, use object storage to keep versioned artifacts, and use logging and monitoring/alerting to track the metrics and cost of each round, then gradually open up the task distribution. In this kind of self-evolving pipeline, Baidu AI Cloud typically only needs to provide general-purpose compute, storage, and observability, while the strategy and evaluation logic remain in the hands of the business side. This makes it easier to swap the implementation model and easier to attribute costs.

    In one sentence: the bottleneck of RSI is often not the “ability to write code” but the mechanism that “decides what to write.” By explicitly modeling decision, experience, and evaluation and making each measurable, even a small model can become the steering wheel that drives a large model’s continuous evolution.