AI Agent Architecture with Self-Evolution Capabilities: How Skills, Failure Memory, and Preferences Compound Across Sessions

    Most AI Agent implementations are stateless: the developer pre-orchestrates tools and prompts, the agent completes one task, and the session ends. This article breaks down the architecture of self-evolving agents, the design pattern that merges task execution with experience accumulation into a single loop. It covers four core capabilities: automatic skill extraction and reuse, converting failure paths into pre-execution warnings, long-term user preference memory, and automatic orchestration of multi-step workflows. It also compares execution-only frameworks with self-evolving agents, and outlines a five-layer implementation stack (execution, extraction, storage, retrieval, governance) along with the governance rules required to keep the system reliable over time.

    1. The Starting Problem: Why Most Agents Forget Everything Once the Task Is Done

    Over the past two years, a large number of open-source AI Agent implementations have appeared, yet their design paradigms are highly convergent: developers pre-orchestrate the tool chain and prompts, the agent follows those instructions to complete a single task, and then the session ends. This “stateless execution” model carries a structural flaw: experience cannot accumulate across sessions.

    The waste shows up in three forms:

    • Repeated exploration cost: when the same type of task runs a second time, the model still has to plan the steps from scratch, and token consumption and latency barely improve.
    • Repeated mistakes: environment pitfalls hit last time (dependency conflicts, malformed configuration, insufficient permissions) get hit again in the new session.
    • Loss of tacit knowledge: preferences a user mentioned offhand in conversation (“use the faster package manager,” “output logs as JSON”) are all reset to zero next time.

    The core premise of a self-evolving agent is to merge “task execution” and “experience accumulation” into the same closed loop. The rest of this article uses a general architectural view to break down which capabilities make up that loop, how storage is organized, and how risk is controlled in engineering practice.

    2. Capability 1: Automatic Skill Extraction and Consolidation

    2.1 What Counts as a Skill Worth Consolidating

    Not every task should be recorded. The fairly consistent industry criterion requires three dimensions to be satisfied at once:

    1. The step count exceeds a threshold (commonly 5 or more steps); for short tasks, the benefit of consolidation is lower than the storage and retrieval cost.
    2. There is a reusable tool-call sequence, meaning the flow has a clear “read-modify-verify” structure.
    3. The execution result is a success, or at least a “failure that eventually converged to success.”

    Once these three conditions are met, the agent abstracts the current trajectory into a structured document that typically contains: a description of the applicable scenario, preconditions, a step list, the verification method for each step, and known failure points. For directory organization, a two-level “domain/skill-name” structure is commonly used to make later semantic retrieval easier:

    1. ~/.agent/skills/
    2. ├── mlops/
    3. │ └── fine-tune-pipeline/
    4. │ └── SKILL.md
    5. ├── devops/
    6. │ └── deploy-container/ # Created automatically by the agent
    7. │ ├── SKILL.md
    8. │ └── references/
    9. └── review/
    10. └── pr-workflow/
    11. └── SKILL.md

    2.2 How Skills Are Invoked During Reuse

    After consolidation, the user no longer needs to restate the requirement; they only need to invoke the skill explicitly or implicitly. The explicit approach works much like a slash command; the implicit approach relies on semantic matching: when the description of a new task is similar enough to the scenario description of a given skill, the agent proactively loads it as the execution starting point. This is the dividing line in user experience: it turns “re-explain every time” into “teach once, reuse for a long time.”

    3. Capability 2: Retaining Failure Paths and Issuing Advance Warnings

    Traditional frameworks keep only successful trajectories, which actually discards the most information-dense part. A more mature approach brings failures into memory as well, but changes their purpose: instead of serving as an execution template, they serve as a risk advisory list.

    A typical scenario: the first time a containerized application is deployed to a cluster, the agent submits the resource manifest directly and fails because fields in the manifest are invalid; it then switches to a path of “template rendering + parameter validation + canary release” and succeeds. What gets written into the skill at this point has two parts: the correct steps, plus a failure-point annotation stating that “missing field validation causes the submission to be rejected.”

    The next time a similar task starts, the agent emits a warning before execution:

    1. [pre-check] Detected skill deploy-container
    2. [warn] The resource manifest must pass schema validation first; historical failure cause: missing fields
    3. [action] Validation step inserted, continuing execution

    The order of “warn first, then execute” is critical. It converts after-the-fact troubleshooting into up-front interception and directly reduces mean time to repair.

    4. Capability 3: Long-Term Memory of User Preferences

    Preferences and skills are two different kinds of knowledge: a skill describes “how to do it,” while a preference describes “how it should preferably be done.” Storage is therefore usually separated: preferences go into an independent memory layer, kept in key-value or vector form, and injected into context before each task planning pass.

    Common preference dimensions include: package manager and build tool choice, code style and formatting rules, logging and output format, commit granularity and branch strategy, and whether high-risk operations may be executed automatically. One correction from the user writes the preference, and it takes effect by default afterward without repeated declaration.

    Engineering-wise, preferences need priority and conflict-resolution rules: explicit instruction > long-term user preference > agent default policy. Otherwise the wrong behavior appears in which a user’s ad-hoc request A gets overridden by historical preference B.

    5. Capability 4: Automatic Orchestration of Multi-Step Workflows

    When an agent runs a chain end to end (for example, retrieve → fetch → summarize → deduplicate → structured output), the most valuable output is not the result itself but the reusable orchestration of that chain. In implementation, the flow is usually abstracted into a directed step graph where each node declares its inputs, outputs, and failure retry policy, then serialized and written to disk alongside the skill document.

    1. skill: research-digest
    2. steps:
    3. - id: search
    4. retry: 2
    5. - id: fetch
    6. depends_on: search
    7. - id: summarize
    8. depends_on: fetch
    9. - id: dedup
    10. depends_on: summarize
    11. - id: render
    12. depends_on: dedup

    With explicit dependency declarations, the agent can perform parallelization and resume from a breakpoint instead of running the whole thing serially from the start every time.

    6. Comparison with Traditional Execution-Oriented Frameworks

    Dimension Execution-oriented framework Self-evolving agent
    Cross-session state Essentially none Skill library + preference memory
    Time for similar tasks Essentially unchanged Decreases with reuse count
    Error handling Retry within the current run Consolidated into pre-checks
    User interaction cost Re-explain every time One correction, effective long term
    Explainability requirement Lower High; retrieval and audit capabilities needed

    It is worth stressing that evolution capability comes at a cost: storage keeps growing, retrieval noise rises, and error experience that is trusted too much amplifies failures. A self-evolving architecture must therefore ship with governance mechanisms and cannot emphasize benefits alone.

    7. Implementation Architecture and Governance Essentials

    A runnable minimal solution usually consists of five layers:

    1. Execution layer: handles tool invocation and step orchestration.
    2. Extraction layer: decides whether a trajectory meets the consolidation conditions and generates the structured skill document.
    3. Storage layer: skill library, preference library, failure-point index, which can be backed by a file system or object storage.
    4. Retrieval layer: recalls candidate skills based on semantic similarity, with a similarity threshold and a maximum candidate count to avoid false recalls.
    5. Governance layer: version management, confidence scoring, periodic regression validation, and redaction of sensitive information.

    The governance layer is the most easily overlooked, yet it determines whether the system stays usable in the long run. At least four rules are recommended: skills carry a version number and their creation source; confidence rises with successful runs and drops with failures; regression is run periodically against a fixed test case set to retire stale skills; and paths, keys, and internal addresses are redacted and whitelist-checked before any write. High-risk operations (deleting data, changing production configuration) should keep a human confirmation step and must not be auto-approved just because “the agent remembers.”

    If the setup is carried on general-purpose cloud capabilities, object storage can hold skill packages, a message queue can decouple extraction from execution, a container platform can run the execution sandbox, and logging plus monitoring and alerting services can track reuse rate and failure rate. This turns “evolution” into observable, measurable engineering metrics rather than black-box behavior.

    8. Conclusion

    The next stage of competition for agents will not be about how nicely a single task is completed, but about whether experience can be structurally consolidated, safely reused, and continuously validated. Automatic skill consolidation solves “knows how to do it,” failure retention solves “stops repeating mistakes,” preference memory solves “fits the user’s taste,” and orchestration plus governance solves “scales.” Only when all four are in place does an agent truly become a productivity asset that gains value with use, rather than a mere tool.