How Large Language Models Use Memory to Evolve Across Versions

    Large language model systems improve through more than larger model parameters. Their prompts, tool workflows, task decomposition strategies, error-handling rules, and validation mechanisms also shape performance. This article explains how structured self-improvement memory helps agent frameworks preserve lessons from past successes and failures, migrate those lessons to new models, and evolve safely through evaluation, controlled deployment, and rollback.

    In recent years, advances in AI agent systems have depended on more than the scale of the underlying model. The prompts, tool-use workflows, task decomposition strategies, error-handling rules, and result-validation mechanisms built around the model also have a major impact on system performance.

    These supporting control layers are commonly referred to as agent frameworks or runtime frameworks. They function as an execution system wrapped around the model: the model handles understanding and reasoning, while the framework organizes tasks, invokes tools, checks results, and triggers retries or corrections when something goes wrong.

    The problem is that traditional optimization often preserves only the code for the current version. It does not preserve why the code was designed that way, which changes previously failed, or which rules were effective only for a particular model. When the underlying model changes, a framework that once worked well can quickly become unreliable.

    The key to solving this problem is not simply copying old configurations. Instead, the system needs improvement memory that is queryable, explainable, and transferable.

    1. What Is Self-Improvement Memory?

    Self-improvement memory is a collection of structured experience accumulated by an agent while executing tasks and optimizing its framework. It is not the same as chat history, nor is it a complete archive of every historical output. Its purpose is to extract information that is genuinely useful for future decisions.

    A complete improvement record should include at least the following:

    1. Task context: What problem was the optimization intended to solve? What were the input conditions and constraints?
    2. Original approach: Which prompts, tool chains, or execution workflows were used before the change?
    3. Modification: What logic was added, removed, or adjusted?
    4. Reason for the change: Why was the change necessary, and which failure mode was it intended to address?
    5. Validation results: What test set and evaluation criteria were used, and what results were obtained?
    6. Scope of applicability: Which task types, model capabilities, or runtime environments does the experience apply to?
    7. Risks and limitations: Could the change introduce side effects? In which situations should it not be used?
    8. Rollback information: How can the system return to the previous stable version if problems occur?

    From an engineering perspective, this type of memory is closer to a change log with causal explanations than to a simple version backup. It records not only what changed, but also why it changed, when it works, and when it may fail.

    2. Why Can an Old Framework Perform Worse After a Model Upgrade?

    Many teams find that the same agent framework behaves differently across models. Several factors typically explain this variation.

    2.1 Differences in Instruction Following

    Models differ in how sensitive they are to prompt hierarchy, formatting constraints, role definitions, and context order. A complex prompt designed for one model may produce instruction conflicts, lost priorities, or unstable output formats when migrated to another.

    2.2 Differences in Tool-Calling Behavior

    Some models tend to analyze a problem before calling a tool, while others may act immediately even when information is incomplete. If the old framework contains interception rules designed for only one behavioral pattern, a model change may cause it to incorrectly block normal operations or allow high-risk calls to pass through.

    2.3 Unrecorded Assumptions

    Many engineering rules are created through long-term trial and error. For example, a validation step may exist specifically to prevent the model from submitting the same result repeatedly. A seemingly unnecessary step may actually prevent empty tool responses from propagating through the workflow.

    If the code is preserved without the original design intent, a future optimizer may mistakenly remove these rules as redundant.

    2.4 Failure Experience Is Not Incorporated

    When a system stores only successful cases, it may repeatedly try approaches that have already been proven ineffective. Valuable memory often comes from failure: which strategies cause tool-call loops, which prompts lead to excessive explanations, and which retry policies amplify errors. These lessons should be recorded and used in subsequent decisions.

    3. From Code Inheritance to Experience Inheritance

    A conventional migration process often copies the old framework directly:

    1. Old model + old framework
    2. ↓
    3. New model + old framework

    This approach assumes that the model and framework are fully compatible, but that assumption is often incorrect. A more reliable process is:

    1. Historical framework + improvement memory + analysis of new model capabilities
    2. ↓
    3. Generate a migration plan
    4. ↓
    5. Test, evaluate, and roll back

    Improvement memory acts as a translation layer. It does not require the new model to mechanically reuse old rules. Instead, it helps the new model understand why those rules were created and then reimplement them according to its own behavior.

    For example, a historical lesson might be represented as follows:

    1. Observed behavior: The model often generates a conclusion immediately after calling a data-query tool.
    2. Cause: There is no completeness check for the returned data.
    3. Action: Add field validation and evidence confirmation before generating the final answer.
    4. Scope: Tasks involving structured data queries.
    5. Risk: Do not enforce this process rigidly for open-ended question answering.

    After the underlying model changes, the system can identify the core requirement: conclusions must be based on complete tool results. It does not need to copy a particular prompt verbatim.

    In this way, migration becomes a process of reimplementing goals and constraints rather than copying code.

    4. A Complete Self-Improvement Loop

    A continuously evolving agent should establish at least the following feedback loop.

    4.1 Task Execution

    The system first completes a task using the current framework version. It records the input, model output, tool-call trace, exceptions, and final result. Execution records should be as structured as possible to support later analysis.

    4.2 Automated Evaluation

    Evaluation should not focus only on whether the final answer appears correct. It should cover multiple dimensions:

    • Whether the task was completed;
    • Whether facts and calculations were accurate;
    • Whether tool calls were necessary;
    • Whether repeated execution occurred;
    • Whether safety constraints were violated;
    • Whether the output met formatting requirements;
    • Whether cost and response time remained within reasonable limits.

    For high-risk tasks, human sampling or an independent validator should also be introduced. This prevents the system from evaluating itself against an incorrect standard.

    4.3 Failure Attribution

    When a problem is detected, the system should not immediately modify the prompt. It first needs to determine the source of the failure:

    • Incorrect model interpretation;
    • Poor task decomposition;
    • Unclear tool descriptions;
    • Missing context;
    • Insufficient validation;
    • Poorly designed retry logic;
    • Abnormal external data.

    Only after identifying the cause can the system make targeted changes instead of engaging in unfocused trial and error.

    4.4 Candidate Changes

    Based on failure records, the system can generate multiple candidate solutions. These may include changing the task decomposition order, adding an intermediate check, modifying tool-selection conditions, or simplifying an overly complex prompt.

    Candidate changes should not be deployed immediately. They need to be tested in an isolated environment first.

    4.5 Comparative Validation

    The new and old versions should be evaluated against the same set of test tasks. In addition to average scores, the evaluation should examine worst-case performance, anomaly rates, and safety boundaries.

    A version that delivers a slight average improvement but causes a significant increase in extreme failures is usually not suitable as a direct replacement for a stable version.

    4.6 Writing the Experience to Memory

    Only validated experience should enter long-term memory. Each record should include the reason for the change, supporting evidence, applicable conditions, and limitations. This prevents an isolated success from being mistaken for a general rule.

    4.7 Release and Rollback

    New versions should be released in stages. They can first be tested on a small set of tasks before coverage is gradually expanded.

    If monitoring detects higher error rates, abnormal tool usage, or an increase in safety incidents, the system should immediately roll back to the most recent stable version.

    5. Designing Transferable Experience Representations

    To transfer experience across models and tasks, the representation should minimize dependence on model-specific wording. A useful approach is to divide memory into three layers.

    Layer 1: Goals

    This layer describes what the system should achieve, such as:

    • Avoid generating definitive conclusions without evidence;
    • Ensure that critical fields are validated before submission.

    Layer 2: Strategies

    This layer describes general methods for achieving the goals, such as:

    • Add an evidence check before final output;
    • Trigger an additional query when a tool returns incomplete data.

    Layer 3: Implementations

    This layer records the specific prompts, code logic, tool parameters, and workflow nodes used to implement the strategy.

    The implementation layer is most sensitive to model differences. During migration, it should be regenerated when necessary rather than copied directly.

    This layered design prevents a specific implementation from being mistaken for the only possible solution. When the model changes, the goal and strategy layers can remain stable, while the implementation layer is reorganized around the new model’s behavior.

    6. Memory Systems Cannot Grow Without Limit

    If every historical experience is retained permanently, the memory system will eventually become a collection of noise. It therefore requires regular maintenance.

    First, experiences should be deduplicated and merged. Multiple records may describe the same failure pattern and should be abstracted into a higher-level rule.

    Second, each experience should include a confidence level and the date of its most recent validation. A rule that has not been tested for a long time should not continue to receive high priority.

    Third, the system should distinguish among stable knowledge, experimental approaches, and deprecated experiences. These categories should not be mixed together.

    Retrieval should also go beyond keyword matching. A better approach is to consider task type, failure mode, model capabilities, environmental constraints, and experience confidence. The system should prioritize memories that are genuinely relevant to the current problem.

    7. Safety Boundaries for Recursive Self-Improvement

    Self-evolution does not mean that a system should be allowed to modify itself without restrictions. Production environments require explicit human control points.

    First, the scope of permitted changes should be limited. A model may adjust prompts and workflow parameters, but changes involving permissions, data access, security policies, or core business rules should require approval.

    Second, candidate changes should be tested in a sandbox. Automatically generated modifications should run in an isolated environment and must not directly access sensitive data or perform irreversible operations.

    Third, complete audit records should be retained. Each change should record who proposed it, what was modified, the test results, the approval process, and the deployment time.

    Fourth, hard invariants should be established. For example, the system must not bypass identity verification, expand data-access permissions, or delete audit logs. These constraints must not be left for the optimizer to decide.

    Fifth, an independent evaluation mechanism should be used. The improvement system and the evaluation system should remain sufficiently separate so that the agent cannot modify the evaluation criteria to create the appearance of progress.

    8. Implications for Enterprise Agent Development

    The focus of agent competition may gradually shift from single-response quality to long-term evolution capability. A mature system should not only answer the current question. It should also know which problems it encountered previously, which approaches have been validated, how the current model differs from historical models, and what side effects a proposed change might introduce.

    Organizations can begin building this capability within a limited scope:

    1. Establish structured execution logs for critical tasks;
    2. Define standardized labels for common failure modes;
    3. Place prompts, tool workflows, and evaluation sets under version control;
    4. Record the reason, evidence, and rollback point for every change;
    5. Introduce automatic candidate-solution generation in test environments;
    6. Use staged deployment to evaluate long-term benefits;
    7. Eventually build experience transfer across models and task types.

    Recursive self-improvement does not mean allowing a model to grow independently of engineering management. It means systematizing the process of trial, summarization, validation, and reuse.

    Reliable continuous evolution must be built on observability, explainability, evaluation, and rollback.

    From this perspective, future large language model systems may no longer be static software that is trained once and used indefinitely. They may become continuously evolving systems with engineering memory. The model handles reasoning, memory accumulates experience, evaluation determines what works, and governance defines the boundaries.

    Only when these four elements work together can agents move from “a model change requires starting framework tuning from scratch” to “the system preserves experience and adapts to change.”