Agent Self-Evolution Memory: How to Keep Optimization Results from Decaying After a Model Switch
This article explains why harness optimizations tuned for one large language model often lose value—or even hurt performance—after switching to another model, and how a self-improving memory can help. It covers the root cause of cross-model transfer failures, a minimal structured memory entry with fields such as hypothesis, evidence, scope, and status, and a five-step engineering workflow for building an optimization loop that can be inherited across models. It also lists common pitfalls and risks, including treating memory as a cache, unbounded rule growth, and insufficient cost control. You will learn how to record not just what changed, but why it changed and where it applies, so an agent can keep building on prior experience instead of restarting from scratch.
1. Background: Faster Model Iterations Are Devaluing Optimization Work
Over the past year, the pace of large language model (LLM) capability improvements has accelerated significantly, and agents have moved from demos into real business workflows. In practice, developers commonly take a pragmatic approach: instead of modifying a model’s internal parameters, they build a “runtime support layer” around the model, often called a harness. This harness includes system prompts, tool descriptions, invocation orchestration, input/output validation, retry logic, and interception rules. Through repeated trial and error across many tasks, this support layer can be refined to a high degree, and the model’s pass rate on real tasks improves accordingly.
The problem is that these optimization results depend heavily on the current model’s behavioral characteristics. Once the underlying model is replaced, carefully tuned rules, prompts, and interceptors may become not only unhelpful but actively harmful. The industry has observed a counterintuitive phenomenon: a harness deeply optimized for one AI coding tool can score lower on another model than that model’s unoptimized baseline configuration. This shows that “optimization” is not the same as “knowledge.” Without context, optimization artifacts degrade into noise.
2. Root Cause: Results Are Preserved, but the Reasons Are Lost
The fundamental reason cross-model transfer fails is a structural loss of experience. During migration, teams typically preserve only the final code and rules, but not the motivation, evidence, and applicable scope behind each change. When a new model faces a complex set of constraints, it cannot tell which rule solved which type of failure, nor can it identify which approaches have already been disproven.
This leads to three typical failure modes:
- Deleting critical logic: removing a branch that serves as a fallback for a fatal defect, treating it as redundant code.
- Repeating ineffective attempts: re-running approaches already proven useless, wasting budget and iterations.
- Oscillating rewrites: switching back and forth between multiple local optima, causing metrics to decline rather than improve.
The following illustrative pseudocode shows how an optimization loop without memory can get stuck:
# No memory: the optimizer only sees the current score and codefor step in range(max_steps):candidate = mutate(current_code) # no motivation, no evidencescore = evaluate(candidate)if score < best_score:current_code = best_code # rollback, but without knowing why# the same class of error may be reintroduced repeatedly
3. Approach: Continuous Recursive Self-Improvement and Self-Improvement Memory
One direction that has drawn considerable industry discussion is upgrading recursive self-improvement from “one-time tuning” to “continuous evolution,” known as continuous recursive self-improvement. Its key component is self-improvement memory: not a simple conversation history, but a structured development log designed for the optimizer that records what was done, why it was done, and under what conditions it worked.
A minimal usable memory entry can include the following fields:
{"id": "exp-0421","problem": "Parameter truncation in long-context tool calls","hypothesis": "Overly long tool descriptions dilute attention","change": "Compress tool descriptions and explicitly declare required fields","evidence": {"pass_rate": [0.61, 0.78], "samples": 200},"scope": {"model_family": "General A", "task": "code repair"},"status": "verified","rollback": "exp-0398"}
The scope and status fields are central to cross-model transferability: the former declares the applicable boundary, while the latter distinguishes between “verified,” “pending,” and “falsified.” When the model changes, the optimizer prioritizes reusing verified entries, skips falsified entries, and re-samples pending entries for validation.
4. Engineering Implementation: A Five-Step Inheritable Optimization Loop
- Establish a baseline. Fix the evaluation set, random seed, and budget, and record the initial configuration score to avoid distorted comparisons later.
- Record changes in a structured way. Every change must include motivation, hypothesis, evidence, and a rollback point; changes missing required fields do not enter the main branch.
- Layer the memory. Divide memory into task-level, tool-level, and global-constraint levels to reduce retrieval noise and prevent rules from conflicting with each other.
- Re-validate after migration. After switching models, first run a small-sample regression, keep only entries that pass the threshold, and downgrade the rest to pending.
- Archive and prune periodically. Deduplicate and merge entries that are long ineffective or repetitive to control context length and invocation costs.
On the engineering side, this loop can be supported by general-purpose capabilities: use object storage to store memory entries and evaluation artifacts, use a message queue to decouple optimization tasks, use a container platform to host reproducible evaluation environments, and use logging and monitoring/alerting services to track pass rates and cost fluctuations. If you use relevant general-purpose capabilities from Baidu AI Cloud, the same design goals are recommended—“reproducible, auditable, and rollback-capable”—rather than chasing a single-point metric.
5. Common Pitfalls and Risks
- Treating memory as a cache. Caches focus on speed; memory focuses on causality. The two should not be conflated.
- Unbounded rule growth. More constraints make conflicts more likely; set an upper limit on the number of rules and define priorities.
- Looking only at the overall score. Metrics should be observed by task type to avoid local improvements masking overall degradation.
- Ignoring cost. Each validation round consumes budget; set early-stopping conditions and caps on sample size.
- Over-automation. High-risk changes require human review, especially rules involving permissions and data access.
6. Conclusion
Models will be updated and tools will be replaced, but the knowledge of “why a change was made this way” should not be lost along with them. By turning the optimization process into structured, evidence-backed, transferable self-improvement memory, an agent can continue to evolve on top of existing experience after a model switch, instead of starting from zero every time.
