Cross-Model Transfer of Agent Framework Experience: Recursive Self-Improvement Without Starting Over

    Optimized agent runtimes often lose performance when swapped onto a new model because the snapshot keeps what changed, not why. This article explains the failure modes and a memory-based pattern—intents, failed experiments, and protected components—so framework improvements can transfer across models.

    Background: Agent Runtimes vs. Underlying Models

    Large language models often have tens of billions of parameters, so most developers cannot edit weights. A typical agent system therefore wraps the model in a runtime: prompt templates, tool descriptions, calling policies, output checks, and context management. That layer decides how the model reasons, when it uses tools, and how it recovers from errors.

    In engineering terms, recursive self-improvement (RSI) is usually a loop: run tasks, evaluate results, change the runtime, run again. The object being edited is the framework, not the model. Over many iterations the framework fits a given model’s habits and task success rates rise.

    The Problem: Scores Drop After a Model Swap

    Recent work reports a counterintuitive result. A runtime that was heavily optimized on one model can score worse on another model than that model’s own default framework. Gains are model-specific and do not transfer by copy-paste.

    For teams, model upgrades are routine. If every swap means retuning from scratch, prior iteration cost is wasted.

    Root Cause: Outcomes Are Kept, Reasons Are Lost

    Runtimes are usually handed off as a final code or config snapshot. The snapshot shows what the system is, not why. Three kinds of information go missing:

    1. Change motive: which failure a rule was meant to fix.
    2. Failed experiments: approaches already tried and shown not to work.
    3. Constraints: whether a seemingly redundant interceptor still blocks a severe class of errors.

    Without that context, a new model’s optimizer tends to (a) delete “redundant” code that actually patched a critical defect, or (b) retry disproven ideas and burn evaluation budget.

    It is like inheriting a repository with no commit messages or changelog: every line is readable, but any edit is risky.

    Approach: Put Reasons into Memory

    Each change should carry a structured decision record, and later optimization must read those records. Four points:

    Record intent and evidence. For every edit, log the component, the problem, supporting eval data or logs, and whether the change was kept, reverted, or failed.

    Keep failed attempts. Negative results are as useful as successes; they stop repeated search.

    Mark protected components. Critical fixes should be flagged so delete or large rewrites require a check.

    Use a model-agnostic representation. Store memory as natural language plus structured fields, not a model-internal format, so it can move between models.

    Illustrative data structure (adapt fields to your team):

    1. from dataclasses import dataclass, field
    2. from typing import Literal
    3. @dataclass
    4. class ChangeRecord:
    5. change_id: str
    6. target: str # component: prompt, tool spec, interceptor, etc.
    7. intent: str # problem the change addresses
    8. evidence: str # eval results or log summary
    9. outcome: Literal["kept", "reverted", "failed"]
    10. protected: bool = False # critical fix; do not treat as dead code
    11. tags: list[str] = field(default_factory=list)

    Before proposing edits, the optimizer should load related records into context:

    1. def build_memory_prompt(records: list[ChangeRecord]) -> str:
    2. lines = ["## Change history (read before modifying)"]
    3. for r in records:
    4. flag = "[CRITICAL FIX — do not remove]" if r.protected else ""
    5. lines.append(
    6. f"- [{r.outcome}] {r.target}: {r.intent} {flag}\n"
    7. f" Evidence: {r.evidence}"
    8. )
    9. return "\n".join(lines)

    Deletes need a separate gate:

    1. def can_remove(target: str, records: list[ChangeRecord]) -> bool:
    2. """Refuse removal if a protected record exists for this component."""
    3. return not any(r.protected and r.target == target for r in records)

    This is a sketch, not a library. Real systems need your own storage and evaluation pipeline.

    Engineering Steps

    1. Record every change. Write a structured record with the edit; reject commits that lack motive or evidence.
    2. Store failures too. Keep failed designs and why they failed.
    3. Retrieve before editing. Query by component and tags; inject only relevant records to avoid overload.
    4. A/B on migration. Run the transferred runtime and the new model’s default on the same regression set. If transfer is worse, check whether key records were missed.
    5. Compress periodically. Merge similar entries; keep conclusions and evidence, drop long process notes.

    Risks

    Stale memory. After capability shifts, old conclusions may be wrong. Tag records with model version or conditions and re-validate after a swap.

    Frozen wrong conclusions. A noisy eval can mislead later search. Attach enough evidence and sample-size context.

    Over-protection. Too many protected pieces shrink the search space and can trap a local optimum. Reserve flags for fixes with a clear failure history.

    Biased eval sets. If regression coverage is weak, transfer judgments are misleading. Expand and recalibrate the suite.

    Alignment with Standard Engineering Practice

    The idea matches commit messages, incident postmortems, and architecture decision records (ADRs). Agent-runtime memory extends those practices to model-driven auto-optimization.

    The practical payoff: changing models need not reset tuning. Experience becomes a searchable, checkable, transferable asset.