Experience Inheritance for Recursive Self-Improvement in Large Language Models: A Practical Guide
Why do carefully tuned agent frameworks often break when you switch to a new large language model? This article examines the experience inheritance problem in recursive self-improvement (RSI): optimization knowledge is frequently stored only as final code and rules, while the intent, evidence, and applicability boundaries behind each change are lost. It introduces a structured self-improvement memory mechanism that turns optimization history into transferable assets, and walks through normalization, capability probing, adaptation layers, canary rollout, and evaluation loops needed to inherit experience across models. Includes a platform-agnostic pseudocode framework, a memory lifecycle model, and a best-practices checklist for building self-improving systems that remain verifiable, reusable, and rollback-safe.
Experience Inheritance for Recursive Self-Improvement in Large Language Models: A Practical Guide
As large language models evolve rapidly, the outer orchestration layers of AI agent applications—prompt systems, tool-calling rules, and guardrails—have grown increasingly complex. Many teams have discovered a frustrating pattern: the heavily tuned “outer framework” that took extensive trial and error to build around one model often performs no better on a new model, and may even underperform the new model’s default configuration.
The root cause is not simple “model incompatibility.” It is that optimization experience loses critical context during migration: teams preserve the results of changes as code and rules, but not the intent, evidence, and applicability boundaries behind each modification.
For recursive self-improvement (RSI) to work in practice, a system must do more than “know how to change code.” It must also “remember why a change was made, who it was made for, and under what conditions it works.” This article explores an engineering-oriented self-improvement memory mechanism that turns the optimization process into transferable assets, and outlines a practical path for cross-model inheritance.
1. Why Frameworks Break After a Model Swap: Lost Reasons, Not Lost Code
An agent application typically consists of the model itself plus an outer orchestration framework. The model handles understanding, reasoning, and generation; the outer framework handles prompt organization, tool selection, parameter constraints, failure retries, safety interception, and output validation. What the industry usually calls self-improvement is rarely direct weight modification—it is mostly optimization of this outer layer.
Around one model, a system can discover an effective set of rules through repeated trial and error: a certain prompt needs stronger format constraints, a certain tool call needs parameter validation beforehand, certain failure types need to trigger retries, certain outputs need to be blocked. Each rule looks like a “patch” on its own, but together they form a body of engineering knowledge with historical reasons embedded in it.
The problem: when the underlying model is replaced, the old framework is usually copied over wholesale as “final code.” The new model sees a pile of rules, prompts, and interceptors—but has no idea why they exist. This produces three typical failure modes:
- Deleting effective patches: the new model judges some validation code as redundant and removes it, even though it once fixed a fatal bug.
- Repeating failed approaches: prompt strategies already proven ineffective get retried from scratch.
- Overfitting to the old model: old rules may encode the previous model’s specific quirks; blindly carrying them over can suppress the new model’s own capabilities.
The core of cross-model migration is therefore not “copying the framework” but “copying the experience.” Experience should include, at minimum: modification intent, change content, validation evidence, failure counter-examples, applicability boundaries, and rollback conditions.
2. Self-Improvement Memory: Turning the Optimization Process into Structured Assets
A workable approach is to introduce a self-improvement memory mechanism that upgrades each optimization from a “code diff” to a “structured memory entry.” An entry should record not just what changed, but the full decision chain.
1. Minimal Fields for a Memory Entry
A transferable memory entry typically contains:
- Problem scenario: the task, input distribution, and tool conditions under which the anomaly appeared.
- Optimization intent: what the change aimed to solve—accuracy, stability, safety, or cost efficiency.
- Change content: the specific modifications to prompts, tool descriptions, parameter constraints, interception rules, or retry logic.
- Evidence chain: validation set results, failure samples, regression tests, and human review conclusions.
- Applicability boundaries: the model capabilities, context length, tool versions, or task types the change depends on.
- Counter-examples and risks: situations where the change may be harmful, and when it should be rolled back.
- Migration guidance: what to verify first after a model swap, and which parts need to be regenerated.
This turns memory from a “result cache” into auditable engineering knowledge.
2. Memory Layering: Strategy, Tool, Prompt, and Guard Layers
To keep memory entries from becoming scattered, organize them by layer:
- Strategy layer: task decomposition, planning order, failure recovery strategies.
- Tool layer: tool selection criteria, parameter validation, response parsing.
- Prompt layer: system prompts, format constraints, few-shot examples.
- Guard layer: safety rules, output validation, confirmation for sensitive operations.
Layering enables layer-by-layer evaluation during migration: the strategy layer is usually the most transferable, the prompt layer may need rewriting, the tool layer requires capability probing, and the guard layer should always undergo stricter regression validation.
3. The Key to Cross-Model Inheritance: Normalized Representation and an Adaptation Layer
“Inheriting memory” does not mean injecting old memories directly into a new model. It means passing them through normalization, compatibility checks, and adaptive conversion.
1. Normalized Representation
Memory entries should be described using model-agnostic semantic structures. For example, instead of writing “must use a specific delimiter,” write “output must be in a parseable structured format, and missing fields trigger a retry.” The former binds to an implementation; the latter preserves the intent.
2. Capability Probing and Compatibility Checks
Before migration, probe the target model’s capability boundaries: does it support structured output? Tool calling? Is the context window large enough? Is it sensitive to long prompts? For unconfirmed capabilities, never assume they exist—verify them through small-scale experiments.
3. Adaptation Layer Generation
The adaptation layer converts normalized memories into prompts, tool descriptions, and validation logic executable on the target model. It should not directly reuse the old model’s optimal parameters. Instead, it should generate candidate configurations based on the target model, then validate them via regression testing against the evidence chain stored in memory.
4. Canary Rollout and Rollback
Cross-model inheritance must support canary releases. Validate new memories on a small traffic slice first, comparing key metrics between the default framework and the inherited framework. If performance degrades, roll back according to the rollback conditions defined in the memory entries. “Self-improvement” without rollback capability is high-risk automation.
4. Engineering Implementation: A Practical Pseudocode Framework
The following platform-agnostic pseudocode illustrates the basic flow of memory recording, migration, and validation.
from dataclasses import dataclass, fieldfrom typing import List, Dict, Optional@dataclassclass ImprovementMemory:memory_id: strscene: str # Problem scenariointent: str # Optimization intentchange_type: str # prompt/tool/guard/retrychange_payload: Dict # Change contentevidence: List[str] # Validation evidenceboundaries: Dict # Applicability boundariescounter_examples: List[str] # Failure counter-examplesrollback_condition: str # Rollback condition@dataclassclass ModelProfile:name: strsupports_structured_output: boolsupports_tool_call: boolcontext_window: intnotes: Dict = field(default_factory=dict)def normalize_memory(mem: ImprovementMemory) -> Dict:"""Convert memory into a model-agnostic semantic description"""return {"scene": mem.scene,"intent": mem.intent,"change_type": mem.change_type,"semantic_change": mem.change_payload.get("semantic", ""),"evidence": mem.evidence,"boundaries": mem.boundaries,"rollback": mem.rollback_condition,}def compatibility_check(mem: ImprovementMemory, target: ModelProfile) -> bool:"""Check whether the memory depends on capabilities the target model lacks"""required = mem.boundaries.get("required_capabilities", [])if "structured_output" in required and not target.supports_structured_output:return Falseif "tool_call" in required and not target.supports_tool_call:return Falseif mem.boundaries.get("min_context", 0) > target.context_window:return Falsereturn Truedef adapt_memory(mem: ImprovementMemory, target: ModelProfile) -> Optional[Dict]:"""Generate a candidate configuration for the target model instead of copying the old one"""if not compatibility_check(mem, target):return Nonesemantic = normalize_memory(mem)return {"target_model": target.name,"migrated_from": mem.memory_id,"prompt_patch": build_prompt_from_semantic(semantic),"tool_policy_patch": build_tool_policy(semantic),"guard_patch": build_guard(semantic),"validation_plan": mem.evidence + ["target_model_smoke_test","regression_on_counter_examples","small_traffic_canary"]}def migrate(memories: List[ImprovementMemory], target: ModelProfile):candidates = []for mem in memories:candidate = adapt_memory(mem, target)if candidate:candidates.append(candidate)else:log_skip(mem.memory_id, "capability_or_boundary_mismatch")return candidates
The point of this pseudocode is not the interface names but the process constraints: normalize first, then check compatibility, then generate candidate configurations, and always attach a validation plan. Any migration that skips validation should never reach production.
5. Memory Retrieval and Compression: Keeping the Experience Base Manageable
As memory entries accumulate, the system needs retrieval and compression mechanisms. Retrieval should prioritize matching on problem scenario, change type, and applicability boundaries—not simple chronological ordering. Compression can merge entries with duplicate intents, keep representative evidence and counter-examples, and remove entries that are obsolete or already covered by the new model’s native capabilities.
Consider defining a memory lifecycle:
- Candidate: newly created changes with only small-sample evidence.
- Validated: passed regression tests and canary validation.
- Stable: performing reliably across multiple tasks and traffic levels.
- Observation: requires re-evaluation after a model or tool change.
- Archived: superseded by newer capabilities or long unmatched—retained for audit but no longer injected by default.
6. Evaluation Loops and Safety Governance
Cross-model experience inheritance must be paired with an evaluation loop that includes at least:
- Regression set: covers historical failure samples and boundary inputs.
- Counter-example set: specifically validates scenarios that memory entries claim are out of scope.
- Controlled experiments: three-way comparison of the default framework, the inherited framework, and a manually tuned framework.
- Safety checks: interception rules, permission confirmations, and sensitive-operation audits must never be weakened by migration.
- Explainable auditing: every active memory entry must be traceable back to its intent, evidence, and rollback conditions.
When deploying on general-purpose cloud platforms, you can use object storage for memory snapshots and evaluation reports, logging services for migration and rollback events, and monitoring and alerting to observe canary metrics. The key is to connect memory assets with runtime observability rather than letting them become an isolated “prompt repository.”
7. Best Practices Checklist
- Record “why it changed” together with “what changed”—never save only the final code.
- Describe memories in model-agnostic semantic terms to reduce cross-model migration cost.
- Probe capabilities before migration; run canary and regression tests after.
- Define applicability boundaries and rollback conditions for every memory entry.
- Be cautious with prompt-layer memories; prioritize migrating strategy-layer and validation-layer experience.
- Compress the memory base regularly and archive obsolete entries.
- Never push unverified automated changes directly to production.
The value of recursive self-improvement lies not in letting a system modify code endlessly, but in making every improvement a verifiable, reusable, and rollback-safe asset. Cross-model memory inheritance is, at its core, about preserving engineering continuity in an environment of rapid model iteration: new models don’t have to start from zero, and old experience doesn’t turn into scrap when underlying capabilities change. When memory structure, adaptation mechanisms, and evaluation loops are all in place, AI self-evolution moves closer to being a controllable, auditable engineering practice.
