Self-Improving Agent Architecture: Memory, Skills, and Feedback Loops

    This article explains how an AI agent can improve by updating external experience assets—memory, procedural skills, and reflection—rather than automatically changing model weights. It covers separating facts, procedures, and task state; designing memory capacity, provenance, and session consistency; extracting reusable skills from execution traces; triggering reflection at appropriate times; validating and versioning skills; retrieving them safely; measuring actual improvement; and adopting the architecture in controlled phases with auditable, reversible governance.

    Self-Improving Agent Architecture: Memory, Skills, and Feedback Loops

    1. The Essence of Self-Improvement: Updating Experience Assets, Not Automatically Changing the Model

    Many agents can complete complex tasks but struggle to retain the effective experience generated during those tasks. In one session, an agent may discover an environmental constraint, correct the order of operations, or identify a failure mode. If that information is not stored in a structured way after the session ends, the next session may repeat the same trial and error.

    Self-improvement is therefore first a systems engineering problem: how to extract reliable experience from execution traces, store it in the right place, and retrieve it accurately for later tasks.

    A clear boundary is needed here: updating memory, generating operating procedures, or adjusting retrieval strategies is not the same as updating model parameters. The former mainly changes the information and workflows available to the agent; the latter involves training and changes to model weights. This article focuses on the former mechanism: improving task performance through external experience assets.

    This kind of architecture usually includes three cooperating subsystems:

    • Memory management: Stores long-term information such as user preferences, environment facts, and project constraints.
    • Skill management: Stores validated operating procedures, inspection methods, and exception-handling strategies.
    • Reflection triggers: Prompt the system at appropriate times to review a task and determine whether any experience is worth preserving.

    Together, these three subsystems form a basic loop:

    Task execution → evidence collection → candidate experience extraction → classification and storage → validation and publication → later retrieval → revision based on results.

    The value of this loop is not that the agent “remembers more.” It is that the agent reduces repeated mistakes and can reuse correct practices across tasks.

    2. Distinguish Three Types of Information First: Facts, Procedures, and Temporary State

    Before implementing storage, it is important to clarify the lifecycle of different types of information. Otherwise, the system can easily record short-term task details as long-term knowledge.

    2.1 Factual Memory

    Factual memory describes relatively stable information, such as:

    • A user prefers to read the conclusion before reviewing detailed analysis.
    • A project requires dependency checks before changes are made.
    • A runtime environment imposes a capacity limit on temporary directories.
    • A certain type of operation requires human approval.

    Facts need a defined scope. A constraint from one project should not be generalized to all projects by default, and a one-off authorization should not be interpreted as long-term authorization.

    2.2 Procedural Skills

    A skill describes “under what conditions, in what steps, what goal should be completed.” It is not merely a record of success. It is executable knowledge that includes preconditions, operation order, verification criteria, and failure handling.

    For example, “the execution succeeded” is not a skill. But “before deployment, check the target environment, confirm artifact integrity, perform the change in stages, and roll back to the previous version if health checks fail” has reuse value.

    2.3 Task State

    Task state includes current progress, temporary files, one-time error output, and assumptions that have not yet been confirmed. This information primarily serves ongoing work and should be stored in the task context or execution record.

    If task state is injected into all sessions over the long term, it not only increases context cost but may also allow information from old tasks to interfere with new tasks.

    A basic principle therefore applies: long-term storage needs filtering, temporary state needs expiration, and unverified conclusions need to be marked.

    3. Memory Systems: Trade Limited Capacity for Information Density

    Long-term memory should not rely on unlimited appends followed by full retrieval. As records grow, this design leads to duplication, contradictions, stale information, retrieval noise, and continuously rising context costs.

    A lightweight approach is to maintain user information and environment information separately. For example:

    1. Memory
    2. ├── User profile: preferences, communication style, long-term goals
    3. └── Environment facts: project constraints, operating conditions, confirmed rules

    The implementation can use text files or structured storage. The key is not the medium, but capacity management and update semantics.

    3.1 Capacity Limits Are Not Automatic Eviction

    A capacity cap only limits storage size; it does not naturally produce a sound information compression strategy. The system also needs an explicit process:

    1. Determine whether new information is worth long-term storage.
    2. Check whether identical or similar content already exists.
    3. Identify conflicts between old and new information.
    4. Merge duplicate entries and shorten redundant descriptions.
    5. Archive low-value or expired content.
    6. If safe compression is not possible, refuse the write or request confirmation.

    Capacity should be configured according to context budget, information type, and retrieval method. A single fixed number should not be treated as a universal standard.

    3.2 Preserve Source and Time for Facts

    A single conclusion is often insufficient to support reliable updates. A more robust memory entry should include:

    1. Content: Release operations for a specified project require human confirmation
    2. Scope: Specified project
    3. Source: Explicit user statement
    4. Last confirmed: Most recent confirmation time
    5. Status: Active

    This metadata helps the system determine whether the fact applies to the current task, whether it needs to be confirmed again, and whether there is more credible new evidence.

    For user preferences, explicit user statements are usually more reliable than system inference. For environment facts, current inspection results usually reflect the present state better than historical records. Conflict handling should consider the type of information rather than applying a uniform rule that “new records overwrite old records.”

    3.3 Separate Session Snapshots from Real-Time Writes

    Memory may change while a session is in progress. If every write immediately rebuilds the base context, the reasoning basis for the same task may drift continuously.

    An optional design is:

    • Read memory at the start of a session and form a stable snapshot.
    • Place new content generated during the session in a writable area.
    • Notify the current agent of new content through explicit execution feedback.
    • Load the updated long-term memory at the next session.

    This helps maintain consistency within a session and makes it easier to audit which information a decision used. However, critical events such as permission revocation or changes to security rules cannot wait until the next session. They require an independent real-time control mechanism to constrain execution immediately.

    4. Skill Accumulation: Extract Reusable Methods from Execution Records

    Execution logs record “what happened at the time,” while a skill answers “how should a similar problem be handled?” An abstraction step is needed between the two.

    For example, a task may fail because the target directory runs out of space and then succeed after temporary data is cleaned up. Saving the complete log only leaves a historical case. A more valuable skill is:

    “Before bulk writes, estimate the required space and check the target capacity. If capacity is insufficient, stop the operation, process temporary data according to explicit cleanup rules, and continue only after a recheck.”

    This preserves the causal relationship without copying paths and file names that apply only to that one task.

    4.1 Skills Should Have an Explicit Structure

    A reusable skill should include at least the following:

    • Goal: What problem it solves.
    • Applicability conditions: When it can be invoked.
    • Non-applicability conditions: When another approach should be used.
    • Preconditions: Permission, dependency, input, and environment requirements.
    • Execution steps: The ordered operating procedure.
    • Verification method: How to prove that the goal has been achieved.
    • Exception handling: Whether to stop, retry, or roll back after a failure.
    • Risk notes: Possible side effects.

    A structured skill is easier to inspect and invoke than a block of free text, and it is also easier to identify missing critical steps.

    4.2 A Single Success Does Not Equal a Reliable Skill

    A successful task may depend on incidental conditions, such as the environment happening to meet requirements, a small input size, or manual remediation. Without identifying these conditions, the extracted skill may be generalized incorrectly.

    Skill generation should therefore distinguish:

    • Facts that were observed;
    • Inferences about why the task succeeded;
    • Applicability scopes that have not yet been verified.

    For skills involving high-risk operations such as deleting data, changing permissions, or releasing services, automatic activation should not be based on a single success.

    5. Reflection Triggers: Extract Experience at the Right Time

    If the agent is responsible for summarizing entirely on its own, experience capture is easy to miss. If reflection is forced after every operation, the system produces a large number of low-value records.

    A more reasonable approach is to use event-driven triggers. Common trigger conditions include:

    • A task is completed and involved significant failure correction.
    • The same type of error appears repeatedly across multiple tasks.
    • A user explicitly corrects a preference or business rule.
    • A process has been successfully executed multiple times.
    • The actual environment conflicts with existing memory.

    Triggers are responsible only for proposing an inspection opportunity; they should not directly decide what to write. The reflection module still needs to determine whether the experience is stable, reusable, verifiable, and free of sensitive information.

    An illustrative flow is shown below:

    1. After a task ends:
    2. Collect results, failure records, and human corrections
    3. Determine whether reflection conditions are met
    4. If met:
    5. Generate candidate experience
    6. Distinguish factual memory from procedural skill
    7. Check for duplication, conflicts, sensitive content, and risk
    8. Save as pending validation

    Special attention is needed here: the model’s own summary of the execution process may also be wrong. Reflection conclusions should be linked to actual evidence whenever possible rather than relying only on a retrospective narrative.

    6. Validation and Publication: Prevent Bad Experience from Accumulating

    One of the main risks of a self-improving system is that it solidifies incidental successes and incorrect attributions. Once experience assets are continuously retrieved, errors can become self-reinforcing.

    A skill lifecycle is therefore recommended:

    Candidate → Pending validation → Published → Suspended → Archived.

    6.1 Static Checks

    First check whether the content is complete, whether the logic is consistent, whether it contains undefined operations, and whether it contains plaintext credentials, personal information, or overly broad permission requirements.

    Static checks can identify structural problems, but they cannot prove that a process works in a real environment.

    6.2 Isolated Validation

    For executable skills, test typical inputs, abnormal inputs, missing dependencies, and repeated execution in a controlled environment. The tests should examine not only whether execution succeeds, but also whether failures leave inconsistent state.

    6.3 Risk-Tiered Approval

    Low-risk information-organization processes can use a lighter publication threshold. Processes involving production changes, data deletion, or permission changes should require human approval and explicit authorization.

    A skill description cannot replace execution authorization. Even if a skill has been validated, every invocation should still be constrained by the current permission policy.

    6.4 Version Management and Rollback

    Skill revisions should retain versions, change reasons, and validation records. If the failure rate rises after publication, the system should be able to suspend the new version and restore a previously validated version.

    An experience system that only allows additions and does not support revocation does not have a complete self-improvement capability.

    7. Retrieval Strategy: Use Experience Accurately, Not Just Store More

    As memory and skills increase, a new problem is how to avoid incorrect retrieval.

    During retrieval, the system cannot rely only on text similarity. It also needs to check task goals, applicable environments, input types, permission requirements, and validity status. A process designed for a test environment may be highly similar to a production task, but that does not mean it can be applied directly.

    Actual retrieval can be divided into three steps:

    1. Retrieve candidate skills based on the task description.
    2. Check applicability conditions for each candidate.
    3. Load skills that pass the checks into the current context as needed.

    At the same time, the number of experiences loaded simultaneously should be limited so that irrelevant information does not crowd out reasoning capacity. For high-risk tasks, the source, constraints, and validation status should be shown first so that the executor can decide whether the skill is worth adopting.

    8. How to Prove the System Is Actually Improving

    “How many memory entries were saved” and “how many skills were generated” are process metrics. They do not directly prove that capability has improved.

    More valuable outcome metrics include:

    • Whether completion rates for similar tasks increase.
    • Whether the same failure causes occur less often.
    • Whether the average number of retries decreases.
    • Whether the number of human corrections decreases.
    • Whether the rate of incorrect skill retrieval remains acceptable.
    • Whether task cost and elapsed time improve.
    • Whether security incidents and rollbacks increase.

    Evaluation should use a relatively fixed task set and compare results before and after the experience mechanism is enabled. It should also distinguish the source of the benefit: whether memory provided more accurate environment information, whether skills reduced operational errors, or whether the model itself or task inputs changed.

    For long-running systems, it is advisable to clean expired experience periodically and check the effectiveness of frequently used skills. When the environment changes, previously correct processes may also become invalid.

    9. Implementation Path: Build a Controllable Loop First, Then Expand Automation

    Practical implementation can proceed in phases.

    In the first phase, store only user-confirmed preferences and environment facts, and establish source tracking, conflict checks, and deletion capabilities.

    In the second phase, generate candidate skills from repeated tasks and publish them after human review, avoiding automatic execution from the very beginning.

    In the third phase, introduce event triggers, isolated validation, and version rollback so that low-risk experience can gradually move through automated workflows.

    In the fourth phase, use evaluation results to adjust retrieval, triggering, and retirement strategies, and set different publication thresholds for different risk levels.

    For users who do not write code, interfaces can be provided for “view memory, confirm experience, approve skills, suspend use, and restore versions.” However, a simplified interface should not omit underlying governance: source, permissions, validation records, and invalidation status still need to be retained.

    What a self-improving agent truly needs is not an infinitely growing knowledge repository, but a mechanism that can continuously filter, validate, retrieve, and revoke experience. Memory provides stable facts, skills reuse operating methods, reflection identifies opportunities for improvement, and validation and governance determine whether experience deserves to enter the next task. Only when these parts are connected into an auditable and reversible loop can accumulated experience become reliable capability growth.