AI Agent Optimization Memory: Carrying Harness Improvements Across Model Generations

    When an AI agent switches to a new underlying model, a harness that was carefully tuned for the previous one often performs worse than the new model's default configuration. This article explains why that happens: the optimization process delivers the final code but discards the reasoning behind each change. It proposes recording structured improvement memory (motivation, modification, evidence, verdict) so optimization experience becomes an inheritable asset, and covers the engineering requirements and limits of putting such a system into practice.

    1. The Starting Point: Why One Model Switch Turns Hard-Won Code into Dead Weight

    In agent engineering, what actually gets refined over and over is rarely the model weights, which can run to hundreds of billions of parameters. It is the harness wrapped around the model: prompt templates, tool-calling conventions, input and output validation and interception rules, retry and fallback strategies. The model itself is the brain; the harness is the exoskeleton that lets the brain interact with the outside world.

    Recursive self-improvement (RSI), as it is mostly practiced in engineering today, means letting a system automatically optimize this harness through large numbers of trials and errors, rather than modifying the underlying weights directly. After thousands of iterations, the harness ends up fitted almost seamlessly: one interception rule exists specifically to block a class of boundary errors, one prompt fragment exists specifically to correct an ingrained bias in the model.

    The problem appears the moment the underlying brain is swapped for a different model. This highly customized exoskeleton often fails outright. A harness that evolved deeply on model A and performed excellently there can, when migrated unchanged to model B, score even lower than B’s own initial configuration.

    2. Root Cause: The Result Is Kept, the Reason Is Lost

    The core of the migration failure is not in the code itself, but in the decision context behind the code.

    When a mature harness is handed to a new model, the new model (and its optimizer) sees only the final form: dense, complex rules, interceptors that look arbitrary, prompt fragments that are extremely specific. What it cannot see is the original intent behind each change:

    • Which class of fatal error was this interception rule originally written to fix?
    • Which specific defect of the old model was this verbose prompt suppressing?
    • Why was a certain abandoned approach proven ineffective and marked as not worth retrying?

    In other words, the optimization process produced a large amount of tacit knowledge, while the deliverable only solidified the explicit result. Without the “why,” the new model’s optimizer will change things blindly: deleting code that was genuinely a safety net for a fatal bug as if it were redundant, or picking up an old approach that had already been proven useless and running it again. Optimization then degrades from “standing on the shoulders of predecessors” to “starting from zero and stepping into the same pits repeatedly,” and can even regress.

    This is exactly the structural waste that simply adding more compute cannot solve: with every model generation, accumulated experience is reset to zero.

    3. The Approach: Give the Improvement Process a Decision Journal

    To make experience transferable, the key is to record and structure the reasoning behind decisions during optimization, so that it becomes an inheritable asset in the same way the code does. This mechanism can be understood as “self-improvement memory”: the system does not only change code, it also writes an explainable record for every change.

    A valuable improvement memory should contain at least:

    1. Motivation (Why): the specific problem or failure case this change addresses.
    2. Modification (What): what exactly was adjusted in the harness.
    3. Evidence: the change in performance on the evaluation set before and after.
    4. Verdict: whether the approach was adopted, rejected, or only effective under specific conditions.

    An illustrative record structure looks like this (for explaining the idea only, not a specific product format):

    1. {
    2. "change_id": "chg-2041",
    3. "motivation": "The model loses intermediate state during multi-step tool calls, causing final-state validation to fail",
    4. "modification": "Insert state snapshots between tool calls and add a final-state consistency checker",
    5. "evidence": { "before": 0.71, "after": 0.86, "eval_set": "agent-bench-core" },
    6. "verdict": "adopted",
    7. "caveat": "Only benefits models with long context; can be disabled for short-context models"
    8. }

    With memory like this, the optimizer facing a new model no longer looks only at what the code looks like. It can read why each piece of code exists and under what conditions it is effective. It can then decide which changes are model-agnostic general fixes that should be kept, and which are patches for defects of the old model that the new model no longer needs and that can be safely removed.

    4. Why This Enables Experience Inheritance Across Model Families

    Experience can transfer across models because what gets recorded is the problem and the tradeoff, not the specific symptom of one model.

    • The “result” is tightly coupled to the model: a bias in the old model may not exist in the new one.
    • The “reason” is much closer to the structure of the task itself: losing state in multi-step reasoning, drifting away from format constraints in long outputs, tool arguments going out of bounds. These problems are common across different models.

    Once improvement memory settles into a “problem-solution-evidence” form, the new model’s optimizer can treat it as prior knowledge: reuse general strategies that have been verified to work, skip dead ends that have already been disproven, and only try again where the differences are real. Optimization then no longer starts from zero but continues from the height accumulated by the previous generation. This is the form of recursive self-improvement actually worth pursuing.

    5. Practical Points and Boundaries in Engineering

    A few pragmatic points when moving this idea into a real system:

    • Memory must be verifiable, not based on gut feeling: every record should be bound to reproducible evaluation data. Otherwise “experience” degrades into noise and misleads later optimization.
    • Separate general improvements from model-specific patches: explicitly annotate applicability conditions in memory and filter by condition during migration, so old patches are not forced onto a new model.
    • Prevent memory bloat and conflicts: as iterations accumulate, the memory store needs periodic merging, deduplication, and expiry reclamation, with arbitration for contradictory conclusions when necessary.
    • Safety and control: automatically rewriting the harness changes system behavior, so human review, canary validation, and rollback capability should be preserved, especially for online interception rules and permission boundaries.
    • Infrastructure is a prerequisite: keeping memory usable over the long term generally requires reliable storage, an evaluation pipeline, logging, and monitoring with alerting. When building such a platform, mature cloud infrastructure (object storage, container platforms, logging and monitoring services) can carry evaluation and memory management and reduce the cost of building everything in-house. General compute, storage, and monitoring capabilities from a comprehensive platform such as Baidu AI Cloud can serve as one of the foundation options for this kind of engineering.

    6. Summary

    The “experience reset” caused by a model generation change is essentially the optimization process delivering only the result and discarding the reason. Recording “why it was changed this way” in a structured form, so that improvements are both explainable and verifiable, is what allows optimization experience to settle into an inheritable asset independent of any specific model. When experience can be reused across model families, each generation can move forward from the shoulders of the last, and the dependence on simply adding compute decreases accordingly. For engineering teams, rather than re-tuning an entire harness every time, it is better to establish a rigorous “decision journal” for the improvement process as early as possible.