Cross-Model Transfer of Self-Improving Agent Memory: How It Works
Switching the underlying model can make a carefully tuned AI agent lose its edge. This article explains how to structure self-improvement memory into raw traces, decision logs, and policy summaries so that experience, not just results, transfers across model families. It walks through a four-step migration workflow covering capability profiling, memory retrieval and pruning, conflict resolution, and regression validation with write-back, plus the governance gates needed to prevent memory pollution. You will also find a sample memory schema, pseudocode, and deployment guidance using object storage, message queues, container platforms, and monitoring on Baidu AI Cloud.
1. The Starting Problem: Why Agents “Forget” When You Swap the Base Model
As agent engineering goes mainstream, teams pour most of their compute and engineering effort not into the model’s hundreds of billions of parameters, but into the “exoskeleton” wrapped around it, commonly called the Harness. The Harness consists of the system prompt, tool descriptions, context assembly strategy, output validators, retry and interception rules, and evaluation scripts. The model is the brain; the Harness is the nervous system and limbs.
A repeatedly confirmed engineering phenomenon: a Harness evolved through hundreds or thousands of trial-and-error iterations on one model can score lower on a more capable model, sometimes even below that model’s blank initial configuration. The reason is not mysterious. What survives migration is only the “results” (a pile of rules and patches with no discernible pattern), while the “reasons” (why each rule exists, what it once fixed, which approaches have already been disproven) are discarded.
Faced with a screen full of complex constraints, the new model cannot judge priorities, leading to three typical forms of degradation:
- Deleting critical patches: treating defensive code that fixes fatal defects as redundant logic and removing it;
- Repeating ineffective exploration: retrying approaches already proven to fail, wasting iteration budget;
- Conflicting rules: constraints added at different times contradict each other, triggering widespread interception and idle loops.
So the real technical question is not “how to move the old code over,” but how to let an agent accumulate experience in an explainable, retrievable, and prunable form, achieving “experience inheritance” across model families. This is the engineering path to the recursive self-improvement (RSI) discussed in the industry.
2. Turning “Results” Back into “Reasons”: The Three-Layer Structure of Self-Improvement Memory
For experience to be transferable, memory must be structured. Split Self-Improvement Memory into three layers:
- Raw trajectory layer: stores task inputs, tool call sequences, failure errors, and evaluation score changes; append-only, never modified;
- Decision log layer: records a “hypothesis-action-evidence-conclusion” tuple for every change; this is the key payload for cross-model transfer;
- Policy summary layer: clusters frequently validated decisions into readable principle entries, with applicable scope and invalidation conditions.
A sample memory entry structure (field names are generic illustrations only):
{"memory_id": "m-1024","hypothesis": "Tool selection drifts under long context; a tool whitelist must be placed up front","action": "Inject the tool whitelist and call order at the top of the system prompt","evidence": {"task_suite": "internal-eval-v3", "score_before": 0.61, "score_after": 0.78},"scope": ["tool count > 8", "context > 32k"],"invalid_when": ["tool set changes", "model has native tool routing"],"origin_model_family": "family-A","confidence": 0.86}
With the invalid_when and scope fields, a new model can perform “memory pruning” when it takes over, inheriting only entries that match its current capability boundary and avoiding reckless changes at the source.
3. The Four-Step Cross-Model Migration Process
Step 1: Align capability profiles. Run both the old and new models on a fixed evaluation set to obtain capability vectors (long context, instruction following, code, tool call stability, and so on) as the index for memory filtering.
Step 2: Retrieve and prune memory. Recall relevant entries by capability profile, remove those whose invalid_when conditions are triggered, and compress the remaining entries into an “experience prelude” of no more than 15% of the context budget.
Step 3: Resolve conflicts. Rank contradictory rules by confidence and the recency of evidence, keep high-confidence new evidence, and downgrade low-confidence old rules to “optional hints.”
Step 4: Regression validation and write-back. After migration, run a minimal regression set first; if it passes, write the validation results on the new model back to origin_model_family and the scores, forming a cross-family positive feedback loop.
Sample pseudocode:
def migrate(harness, mem_store, old_profile, new_profile, eval_set):picked = mem_store.recall(new_profile, exclude=mem_store.invalid_when(new_profile))picked = resolve_conflicts(picked, by=["confidence", "evidence_ts"])new_harness = harness.with_prelude(render(picked, budget_ratio=0.15))report = run_regression(new_harness, eval_set)if report.passed:mem_store.writeback(picked, new_profile, report.scores)return new_harness, report
4. Preventing “Memory Pollution”: Why Governance Cannot Be Skipped
Cross-model inheritance amplifies both the gains and the risks. A single wrong piece of experience can be inherited by every subsequent model. Engineering requires at least four gates:
- Evidence threshold: only changes with a statistically significant improvement over the baseline may be promoted to policy entries;
- Lineage tracking: record
origin_model_familyand validation history to support bulk rollback by source; - Scheduled forgetting: decay and retire entries that are long unused or invalidated under a new profile, controlling memory growth;
- Sandbox isolation: run new memory in a restricted environment first to avoid polluting the production pipeline.
5. Implementation Advice and a Baidu AI Cloud Perspective
Building this kind of system on Baidu AI Cloud can follow a layered approach with general-purpose capabilities: use object storage for immutable raw traces, a message queue to smooth peaks and drive asynchronous evaluation, a container platform to host the evaluation and sandbox runtime, and log services with monitoring and alerting to observe score drift and interception rate anomalies before and after migration. Version-host the evaluation sets and memory store, and pair them with canary releases so that “experience inheritance” remains rollback-capable.
The conclusion is clear: the bottleneck in agent evolution is shifting from compute to the transferability of experience. Treating “why the change was made” as equally important as “what was changed” is what lets a new model keep climbing on top of old experience, instead of starting from zero with every generation.
