Cross-Model Transfer of Self-Improving Agent Memory: Mechanisms and Design

    This article explains why experience accumulated in an AI agent's harness layer loses value when the underlying model is upgraded, and how to turn that experience into portable assets. It breaks down the four root causes of non-portability, proposes a four-layer memory structure with a model-agnostic intermediate representation, and walks through a five-step migration loop covering extraction, normalization, adaptation, regression, and governance. Engineering guidance on evaluation, gradual rollout, observability, and safety boundaries is included, along with common pitfalls to avoid.

    1. Background: Why Experience Assets Depreciate as Model Iterations Accelerate

    In agent engineering, what gets refined over and over is rarely the base model weights. It is the framework layer wrapped around the model: system prompts, tool descriptions, context organization strategies, failure interception rules, retry and fallback logic, evaluation scripts, and thresholds. This layer is commonly abstracted as the harness, and it determines whether model capability translates into stable business results.

    As the generational cycle of base models shortens, a structural conflict emerges: a framework layer deeply tuned for the previous generation may deliver no gains after migration to a new model, and can even regress noticeably. Publicly reported experiments describe similar behavior — a framework configuration that performed well after multiple rounds of iteration on one model scored below the new model’s initial default configuration when applied directly.

    The root cause is not that “the rules were written wrong.” It is that the memory lost causality: the framework layer preserved only what the final code and rules look like, and discarded why each change was made. Facing a large number of conditional branches and interceptors, a new model cannot tell which changes fixed critical defects and which are historical noise. This produces three typical forms of degradation:

    • Deleting critical patches: code that fixes boundary issues is treated as redundant and removed.
    • Repeating ineffective attempts: approaches already proven useless are executed again, wasting call budget.
    • Stacking conflicting rules: old and new constraints pull against each other, and output stability drops.

    2. Root Causes: Four Dimensions of Non-Portability

    1. Outcome-only memory: only the final state is stored, with no before/after diff or verification evidence.
    2. Model-specific assumptions: prompt wording, formatting preferences, and tool-calling habits are tightly coupled to one model’s distribution.
    3. Evaluation drift: different models have different sensitivity to the same metric, so reusing old thresholds leads to misjudgment.
    4. Missing implicit context: failure samples, boundary conditions, and business constraints are not migrated along with the rules.

    3. Design Goal: Upgrade Experience from a Code Snapshot to a Portable Asset

    A portable experience asset should satisfy four properties: explainable (every rule carries its rationale), verifiable (regression cases and metric deltas exist), trimmable (selectively enabled according to the target model’s capabilities), and rollback-capable (versions and deprecation markers are retained). These four properties decide whether memory can be reused across model families rather than remaining a one-off tuning artifact.

    4. Method Framework: Layered Memory and a Portable Intermediate Representation

    Split self-improving memory into four layers:

    • Fact layer: task constraints, input/output contracts, business invariants.
    • Evidence layer: failure cases, minimal reproductions, before/after metric comparisons.
    • Strategy layer: model-agnostic intent descriptions, for example “apply segmented validation to overly long outputs.”
    • Implementation layer: concrete prompts and code, tagged with the applicable model class and activation conditions.

    During cross-model migration, only the fact, evidence, and strategy layers are transferred; the implementation layer is regenerated for the target model. A sketch of the structure (pseudocode, showing organization only):

    1. MemoryEntry {
    2. id, scope, intent, // intent: model-agnostic
    3. evidence: [ {case, metric_before, metric_after} ],
    4. constraints: [ ... ], // business invariants
    5. impl_variants: [ {model_class, prompt, guards} ],
    6. status: active | deprecated,
    7. version
    8. }

    5. Migration Workflow: A Five-Step Loop

    1. Extract: work backward from the old framework to recover each rule’s intent and evidence; mark rules that cannot be traced as pending verification.
    2. Normalize: rewrite model-specific phrasing into intent descriptions, stripping dependence on exact wording.
    3. Adapt: regenerate the implementation layer based on the target model’s instruction-following and tool-calling characteristics.
    4. Regress: run a “default configuration vs. migrated configuration” comparison on a fixed evaluation set and check whether the migrated version truly beats the default.
    5. Govern: downgrade or retire entries with no gain or negative gain, keeping versions for rollback.

    6. Engineering Practices

    • Evaluation first: build a layered evaluation set (functional correctness, boundary robustness, cost and latency), and fix metric definitions before optimizing.
    • Enable gradually: roll out rules by scope in canary fashion, avoiding a one-time stack that makes attribution difficult.
    • Cost and observability: use logging services, monitoring alerts, and distributed tracing to locate the source of regressions; use message queues and object storage to hold memory entries and failure samples, and container platforms to host reproducible evaluation environments.
    • Safety boundaries: interception rules must distinguish “safety constraints” from “performance patches”; the former must never be trimmed automatically.
    • In general engineering practice on platforms such as Baidu AI Cloud, these capabilities are typically assembled from common categories such as logging, monitoring, storage, and containerized evaluation; refer to the official documentation for specific capabilities.

    7. Common Pitfalls

    • Treating the number of rules as optimization progress while ignoring diminishing marginal returns.
    • Migrating code without migrating evidence, leaving the new model unable to judge trade-offs.
    • Evaluating a new model with old thresholds and drawing wrong conclusions about regression or improvement.
    • Lacking a rollback mechanism, so one bad migration contaminates the entire experience asset.

    8. Conclusion

    The core of cross-model migration is not moving code but moving the “why.” When memory has intent, evidence, and version governance, the framework layer becomes a genuine long-term asset that compounds through rapid model iteration instead of restarting from zero with every model switch.