Self-Improving Memory for LLM Agents: Transferring Experience Across Models

    This article explains why an LLM agent's harness is tightly coupled to its underlying model and why essential design rationale can be lost when the harness is moved to a new model. It introduces a structured, retrievable self-improvement memory that captures triggers, diagnoses, evidence, changes, evaluation metrics, assumptions, and status, then outlines implementation and maintenance practices including cross-model revalidation, cleanup, data governance, and human review.

    1. Background: Why Agents Need Self-Improvement

    An LLM-based agent generally consists of two parts. The underlying model handles reasoning and generation, while the surrounding framework organizes prompts, invokes tools, sets interception and validation rules, and provides validation logic. This framework is often called the harness. In most teams, harness iteration is easier to implement than model training because it does not require changing model parameters; it only requires modifying configuration, code, and rules.

    Recursive Self-Improvement (RSI) refers to a system that uses feedback from its own operation to repeatedly evaluate and modify its harness, thereby improving performance over time. A typical workflow includes executing tasks, collecting results, analyzing failure causes, generating proposed changes, validating them on an evaluation set, and retaining the effective version.

    2. The Problem: Results Transfer, but Rationale Is Lost

    There is an implicit coupling between a harness and a model. A harness that has gone through extensive iteration on one model often compensates for that model’s specific biases. For example, a prompt may correct the model’s tendency to over-decompose steps, and an interceptor may filter a common formatting error. After switching to another model, these compensations may become meaningless or even counterproductive.

    Experiments also revealed a notable phenomenon: when a harness is transferred wholesale to a new model, the system retains only the final code and rules, while the reasons for changing them are not preserved. The optimizer taking over sees a set of rules that appear redundant or mutually contradictory and cannot determine which rules were added to fix specific defects. As a result, it may delete critical remediation logic or retry approaches that have already proved ineffective.

    This shows that the value of a harness lies not only in the code itself but also in the judgment accumulated behind that code. Once that judgment is lost, every model change incurs the cost of repeated trial and error.

    3. Design Approach: Turn Experience into Retrievable Memory

    The proposed approach is to add a layer of self-improvement memory, referred to as experience memory. On each modification, the system stores the context, rationale, and validation results in a structured form. Experience memory should include at least the following information:

    • Trigger event: which run or which type of sample exposed the problem.
    • Diagnosis: the root-cause assessment and the evidence supporting it.
    • Change: the specific modifications to the affected component, rule, or prompt.
    • Validation results: changes in evaluation metrics before and after the modification, including changes in the number of failed samples.
    • Scope of applicability: the preconditions on which the experience depends, such as a certain type of model behavior or task structure.

    The last item is especially important. An experience is valid only under specific conditions. By recording its scope, the system can determine during a model change which experiences need to be revalidated and which can be reused directly.

    An illustrative record structure is shown below:

    1. ImprovementRecord
    2. trigger Task or sample identifier that triggered this change
    3. diagnosis Root-cause assessment of the failure
    4. evidence List of log or sample references supporting the diagnosis
    5. change Name of the modified component and the specific change
    6. metric_before Evaluation metric before the change
    7. metric_after Evaluation metric after the change
    8. assumptions Assumed model behaviors or task-structure preconditions
    9. status Valid / superseded / invalid

    This structure allows the optimizer to see not only the rules themselves but also the reason each rule exists.

    4. Implementation Steps

    1. Establish a fixed evaluation set. The evaluation set should cover common tasks and historical failure cases and should be run in full after every modification. Without stable evaluation, it is impossible to determine whether an improvement is genuinely effective.
    2. Create a record for every modification. A change submission must include the diagnosis and evidence. Changes without this information should not be merged.
    3. Retrieve relevant experience. Before starting a new optimization round, search memory by component name and failure type, and provide the relevant entries to the optimizer as context.
    4. Revalidate after migration. After changing the underlying model, first run the original harness on the evaluation set, then check the assumptions behind each experience record one by one. Entries judged invalid should no longer participate in decision-making.
    5. Clean up periodically. Mark experiences that have been superseded by later modifications as “superseded” so that the optimizer is not misled by outdated rules.

    5. Risks and Considerations

    Experience memory itself can be wrong. If a diagnosis comes from an incidental phenomenon or too few samples, the incorrect experience may be cited repeatedly. Each record should therefore retain links to evidence and be sampled and reviewed periodically.

    Second, memory content may contain business data or user information. It should be de-identified before storage, and access permissions should follow the principle of least privilege.

    Finally, automated optimization cannot fully replace human review. Changes that affect security boundaries or compliance rules should retain a human confirmation step.