Agent Evolving Memory: Cross-Model Experience Transfer and Recursive Self-Improvement (RSI) in Practice

    This article explains how to decouple an agent's accumulated experience from any single underlying model, so that switching models no longer means starting from scratch. It defines a practical and safe boundary for Recursive Self-Improvement (RSI), introduces a layered, model-agnostic memory design (L0–L4), and details an experience-distillation pipeline, a model-switch handover protocol, and a metrics-driven verification loop with rollback. It also covers engineering pitfalls and how to assemble the mechanism from general-purpose cloud services. Readers will gain a concrete, verifiable path from the idea of self-improvement to a sustainable engineering practice.

    1. The Problem: Why Agents Need “Evolving Memory”

    In real development scenarios, an agent system is rarely bound to a single model. You might build an agent framework with one AI coding tool today to handle code retrieval, dependency analysis, and patch generation, then switch to another model tomorrow because of cost, latency, or compliance requirements. If the accumulated experience lives only inside the model’s weights and the conversation context, then switching means starting from zero: the same pitfalls get rediscovered, and the same failure modes recur.

    The original observation is that an agent framework tuned on one model can, after switching models, directly inherit its “past-life memory” and keep iterating. Abstracting this phenomenon yields the core proposition of this article: decouple experience from the model, and on that basis build a recursive, self-improving loop (Recursive Self-Improvement, RSI) that is cumulative, transferable, and verifiable.

    A rigorous distinction is needed first: “memory” here does not mean writing into the model’s internal parameters, but externalized, structured experience assets. What is engineering-achievable is “behavior-level experience inheritance,” not “weight-level knowledge fusion.” Stating this clearly avoids a lot of illusory expectations.

    2. Concept Clarification: What RSI Can Realistically Deliver in Engineering

    In academic discussion, RSI often means a system that can autonomously improve its own architecture and capabilities. In engineering practice, three layers can be implemented safely:

    • Prompt and policy layer: automatically rewriting system prompts, tool-selection strategies, and retry and fallback rules.
    • Workflow and orchestration layer: adjusting task-decomposition granularity, parallelism, and where verification checkpoints sit.
    • Memory and knowledge layer: accumulating reusable experience entries, a failure-mode library, and checklists.

    What cannot be implemented safely, or should not be promised, includes: autonomously modifying its own training weights, autonomously changing permission boundaries, and autonomously disabling safety checks. Any RSI design must explicitly constrain the “improvable scope” to a whitelist; otherwise, the faster it iterates, the greater the risk.

    3. Core Design: Model-Agnostic Layered Evolving Memory

    To make experience transferable across models, memory must be organized by abstraction level: the lower the level, the more general; the higher, the more dependent on specific model characteristics.

    Layer Content Model coupling Transfer difficulty
    L0 Task facts Requirements, constraints, input/output contracts None Very low
    L1 Workflow skeleton Step sequence, dependencies, checkpoints None Low
    L2 Policy heuristics When to retrieve, when to ask, when to converge Low Medium
    L3 Failure modes Typical errors and how to avoid them Medium Medium
    L4 Prompt snippets Specific wording, examples, format constraints High High

    Key engineering principle: cross-model transfer only moves L0 through L3; L4 must be recalibrated on the new model. Forcibly migrating high-coupling prompt snippets is the most common cause of failure in practice—wording that works for the old model may actually reduce adherence on the new one.

    A suggested structure for a memory entry (illustrative, not a specific product interface):

    1. {
    2. "id": "mem-0421",
    3. "layer": "L3",
    4. "scope": "code-refactor/python",
    5. "trigger": "circular imports caused by cross-file renaming",
    6. "action": "build a layered dependency graph first, then commit layer by layer",
    7. "evidence": {"attempts": 3, "verified": true},
    8. "abstain": "do not bulk-rewrite before generating the dependency graph",
    9. "model_agnostic": true,
    10. "confidence": 0.82
    11. }

    The abstain field is especially important: it records “under what conditions this experience should not be used,” which keeps the memory library from turning into a book of dogma.

    4. Experience Distillation: Compressing One Success into a Reusable Entry

    The bridge for cross-model transfer is the distillation pipeline, which breaks into five steps:

    1. Trajectory collection: record the task inputs, tool-call sequence, intermediate artifacts, final results, and verification conclusions.
    2. Attribution analysis: distinguish “success from model capability” from “success from workflow design.” Only the latter is worth persisting.
    3. Abstraction rewrite: replace specific wording with intent descriptions, turning “a phrasing that one model likes” into “an output contract needs to be made explicit.”
    4. Deduplication and conflict resolution: when a new entry conflicts with existing ones, decide whether to keep, merge, or downgrade it based on verification pass rate and scope of applicability.
    5. Canary validation: run the new entry in a shadow environment first, compare it against a no-memory baseline, and only promote it to the official library if metrics do not regress.

    Attribution is the step most easily overlooked. Without it, the memory library is quickly polluted by “accidental successes”; the larger it grows, the lower the return, eventually producing negative transfer.

    5. The Handover Protocol When Switching Models

    When the underlying model is replaced, run a fixed handover procedure:

    • Freeze and snapshot: lock the current memory-library version and keep a rollback point.
    • Capability alignment probing: use a small but comprehensive set of diagnostic tasks to measure the new model’s differences in instruction following, structured output, long context, and tool calling.
    • L4 rebuild: rewrite only the high-coupling prompt snippets; inherit L0 through L3 as-is.
    • Confidence recalibration: rescore the confidence of the same experience on the new model, and move low-scoring entries into an observation area.
    • Dual-track comparison: run the old and new configurations in parallel on the same task batch, and decide on a full switch using three metrics: pass rate, rework rate, and average number of steps.

    The value of this protocol is turning “switching models” from a risky event into a routine operation that is measurable and reversible.

    6. The Verification Loop: No Measurement, No Evolution

    The “evolution” of RSI must be backed by data. At least four categories of metrics are recommended:

    • Task pass rate: the proportion of first-pass, second-pass, and final-abandonment outcomes.
    • Efficiency metrics: average interaction rounds, number of tool calls, and the token-consumption range.
    • Stability metrics: the variance across repeated runs of the same task; high variance signals an unreliable strategy.
    • Memory health: hit rate, misuse rate, conflict rate, and the share of expired entries.

    A rollback mechanism must also be in place: when metrics decline across several consecutive tasks, automatically downgrade to the previous memory-library version and raise an alert. An iterative system without rollback will inevitably drift over long-running operation.

    7. Engineering Implementation and Common Pitfalls

    • Least privilege: separate the permissions for reading/writing the memory library from those for automatic policy rewriting; automatic improvement must not touch safety checks or audit logs.
    • Auditability: every experience must be traceable to a specific trajectory and verification conclusion, to support retrospectives and accountability.
    • Context budget: cap memory retrieval; injecting too much experience squeezes the task context and instead lowers performance.
    • Expiration governance: set a validity period and review cycle for entries; once the tech stack evolves, old experience may become directly obsolete.
    • Privacy and compliance: if trajectories contain business code or data, desensitize them at the collection stage, and decide the storage location and retention period according to organizational policy.

    There are three common pitfalls: first, migrating prompt snippets as if they were general experience; second, skipping attribution and causing memory pollution; third, counting only pass rate while ignoring variance, mistaking accidental success for genuine capability.

    8. How to Integrate with General-Purpose Cloud Capabilities

    To carry the mechanism described above in production, you usually do not need proprietary components; it can be assembled from general categories: object storage for memory-library snapshots and trajectory archives; a message queue to decouple the collection and distillation pipelines; a container platform to host shadow-validation and dual-track comparison tasks; log and monitoring/alerting services for metrics collection and degradation warnings; and key-management capabilities to hold access credentials. Baidu AI Cloud offers corresponding product forms for these general categories, and you can freely combine them according to your organization’s existing tech stack, avoiding a strong lock-in to a single ecosystem.

    9. Conclusion

    The essence of cross-model “experience” inheritance is not to give the new model the old model’s memory, but to distill both successes and failures into model-agnostic engineering assets, and then let strict verification decide which assets are worth inheriting. With experience layering, attribution distillation, canary validation, and rollback in place, Recursive Self-Improvement turns from a concept into a sustainable engineering practice; conversely, automated iteration without measurement only amplifies noise.