Self-Evolving AI Agents: Memory, Skills, and Architecture Choices

    Long-running companion agents and one-off task assistants can both chat, call tools, and run workflows, but underneath they are often not the same class of system. This article explains self-evolution as an application-layer loop built on replayable traces, governed memory, and vetted skills. It describes layered memory for session state, working checkpoints, long-term facts, and preferences; discusses how skills should be proposed, reviewed, versioned, and retired; and compares execution-loop-centric and control-plane-centric architectures. It also covers replaceable runtimes, channels, and models, and recommends a governance-first adoption path so teams can decide when continuous evolution is appropriate and when fine-grained human orchestration is the better fit.

    Self-evolution does not mean the model gets smarter by itself

    What the industry often calls self-evolution is usually not online rewriting of foundation model weights. It is a repeatable loop at the application layer: execute a task, record the outcome, distinguish effective practices from ineffective ones, distill the reusable parts into skills or policies, and selectively inject them into later sessions. For this loop to work, at least three kinds of material must be present at the same time.

    The first is replayable traces. In a complex task, the system should keep structured records of which tools the model called, roughly which parameters it used, where the user corrected it, and whether the goal was ultimately achieved. A chat transcript alone is not enough. Without traces, “learning from experience” remains an impression.

    The second is governable memory. Environment facts, operating conventions, incident lessons, and user preferences should not be mixed into one free-text block. A common approach is to separate them into two kinds of long-term documents. One records the environment and experience, such as repository conventions, release windows, and operations that must not be executed automatically. The other records communication preferences, such as response granularity, whether to lead with the conclusion, and which information should be redacted by default. At the start of a session, inject only the summaries relevant to the current task rather than stuffing all history into the prompt. Full-text or vector retrieval can fill in “what was discussed a few weeks ago,” but retrieval results should still be filtered. Stale facts, one-off verbal instructions, and snippets containing secrets or personal information should not be automatically promoted to long-term memory.

    The third is admission criteria for skills. A skill can be understood as a reusable instruction set with trigger conditions, steps, tool constraints, and failure fallbacks. It should answer: when should it be activated, at what point must it stop and ask a human to confirm, and how is success verified? If the system simply archives successful conversations as-is, later sessions will keep expanding, and noise will quickly overwhelm experience.

    At a schematic level, one loop can be quite simple:

    1. Task completed
    2. -> Extract: goal, steps, tools, user corrections, outcome
    3. -> Judge: reusable? sensitive information? conflicts with existing skills?
    4. -> Write: skill draft or memory patch (pending review by default)
    5. -> Next session: retrieve by task, inject only on match

    “Automatically creating skills” without human spot checks carries risks that are no smaller than the benefits. Once an incorrect step is written into a skill, later tasks will repeatedly amplify it. In production, a more reasonable default is that the system can draft, while maintainers retain publishing authority. Higher automation is more appropriate only in personal experimentation environments.

    Memory should be layered, not a giant prompt

    Understanding memory as “two profiles inside the system prompt” is useful for design, but it is not enough for engineering. At least four layers should be distinguished.

    Session state serves only the current conversation: temporary paths, uncommitted decisions, and tool outputs from the current turn. It should expire when the session ends, or only a summary should be retained.

    Working memory is the checkpoint for the current task: confirmed requirements, hypotheses to be tested, and commands or APIs that have failed. It helps long tasks resume after interruption, but it should not automatically become a user profile.

    Long-term fact memory records stable, verifiable content: project terminology, environment differences, release taboos, and conclusions from past incidents rather than raw logs. Each fact should ideally carry a timestamp, source, and scope of applicability. When the environment changes, old facts should be marked invalid.

    Preference memory records communication and authorization style: response length, whether automatic file edits are allowed, and which directories are read-only. Preferences are not facts, and they cannot override safety policies. For example, if a user once says “always execute directly from now on,” that must not be used to remove confirmation for high-risk operations.

    Retrieval must serve both “remembering” and “forgetting.” Full-text retrieval is suitable for exact recall of commands, ticket numbers, and error keywords. Semantic retrieval is suitable for fuzzy recall of “how did we handle a similar failure last time.” Both should return source snippets so that humans and agents can verify them. Understanding a user across sessions means accumulating stable preferences within the authorized scope, not covertly building a profile that cannot be exported. Users should be able to view, export, correct, and delete these profiles. Content involving secrets, tokens, or personally identifiable information should not enter long-term memory by default. Keep only a pointer such as “this kind of information is stored in the secret management service.”

    Injection strategy should also be restrained. Stuffing all profiles into the beginning of every session wastes context and keeps stale rules active. A more stable approach is to always inject a small number of high-priority rules, retrieve the rest by task, and limit the number and length of retrieved items. When conflicts arise, safety policies take precedence over skills, and skills take precedence over temporary statements made in casual conversation.

    Skills grow over time, but still need software-style management

    Hand-written skills have clear boundaries, can be code-reviewed, and can be versioned. They are suitable for processes that require precise control, such as payments, releases, and permission changes. Skills distilled from use are close to real failure modes: which parameters are often written incorrectly, which checks can detect environment inconsistencies early, and where users usually change requirements. The two approaches are not opposites. Mature teams often let the agent propose and humans merge.

    A maintainable skill should include at least: preconditions for use, inputs and outputs, allowed tool categories, prohibitions, validation methods, rollback or remediation, and the last verification time. If an open skill description format only defines file structure and metadata, its value lies in portability and reviewability, not in binding to a particular runtime. Before sharing a skill, remove intranet addresses, accounts, and business data.

    Skills also rot. After API upgrades, directory renames, or approval process changes, old skills will reliably produce errors. Skills therefore need versions, owners, usage counts, and recent failure rates. Entries that have not been used for a long time or whose failure rates have risen should be downgraded to drafts rather than continuing to be injected automatically. This is also the real meaning of “getting better with use”: the system improves because ineffective experience is retired, not just because the archive gets thicker.

    Built-in skills covering common areas such as research, code collaboration, and delivery operations are a reasonable starting point, but they cannot replace scenario knowledge. Generic steps cannot solve your repository’s branch strategy, change windows, and compliance requirements. Writing these into controlled skills is more reliable than expecting the model to rediscover them every time.

    The execution loop and the control plane solve different problems

    One architecture places a long-running gateway or control plane at the center: session management, channel access, routing, tool execution, state, and permissions are all coordinated by this process. The benefits are a unified entry point, easier policy enforcement, a consistent multi-channel experience, and a single control point for troubleshooting. The cost is that the control plane itself becomes an availability and security boundary, and upgrades, scaling, and fault isolation must be designed separately.

    Another architecture places the agent’s execution loop at the center: perceive, plan, act, observe, and reflect, over and over. Memory and skills are the state and products of this loop. If a control plane exists, it is more like an access and policy layer than the intelligence itself. The benefit is a clear learning loop, suitable for long-running tasks and cross-session improvement. The cost is that once state is dispersed, auditing becomes harder. If the reflection step is unconstrained, the system will turn occasional success into general rules.

    Real systems are often hybrids. Message entry, identity, and quotas sit in the control plane. Task state machines and skill evolution sit in the execution loop. Tool execution sits in an isolated environment. When selecting an architecture, do not ask “who is the center?” Ask instead: who holds state, who can approve skill releases, who can intercept high-risk actions before tool execution, and where does the session resume after interruption?

    Scenarios that run for a long time and need to accumulate domain experience place more weight on memory governance, skill draft review, and trace replay. Scenarios that need fine manual control and deep integration with an existing workspace place more weight on the permission model, human checkpoints, and connections to code review and change tickets. The two can coexist: during exploration, use the execution loop to quickly distill drafts; once stable, move skills into a controlled workflow delivered by the control plane.

    Runtime, channels, and models should be replaceable

    The execution environment does not need to be locked into one form. A local process is suitable for debugging. Containers or sandboxes are suitable for isolating dependencies and restricting the filesystem. A remote terminal is suitable for landing on existing hosts, but permissions must be minimized and audited. Elastic compute is suitable for occasional heavy tasks and can be released when idle to control cost. A lightweight virtual machine can host an always-on gateway, while accelerated instances are enabled only for training, evaluation, or large-batch inference. The principle is that the agent’s default permissions should be less than the operator’s own, outbound network access should be restrictable, and secrets should be injected by a dedicated management facility rather than written into memory.

    Whether the message channel is instant messaging, a collaboration group, or a command line, it should converge into a unified access process. Authentication, session mapping, rate limiting, and content redaction are handled at the edge, and standardized events are then passed to the execution loop. This way, changing channels does not require rewriting skills. In group chats, make it explicit that the bot responds only when mentioned or given specific commands, to avoid writing bystanders’ conversations into long-term memory.

    Model supply should likewise not be hard-coded. The routing layer keeps a unified interface for chat and tool calls and selects different models by task: cheaper models for classification and summarization, stronger models for complex planning and code edits. When switching, run regression tests on whether skills still fit that model’s tool-calling habits, because the same skill is followed to different degrees by different models. Evaluation should look at task success rate, the number of human corrections, and the number of policy-violation interceptions, not just context length or unit price.

    Start with governance before talking about replacement

    If the goal is to replace an existing assistant, first list the capabilities that cannot be degraded: session continuity, tool allowlists, human confirmation points, log retention, multi-channel entry, and replayable failures. Then list the capabilities you hope to add: editable memory, versioned skills, and searchable experience. Use the same set of real tasks for comparison, and record first-time success rate, whether the second attempt takes fewer detours, and whether incorrect skills are blocked. Comparing feature lists alone easily mistakes “can chat and call tools” for “can improve over the long term.”

    A minimum viable governance model can be very concrete. Memory writes go into a pending-review queue by default. Skill releases require diffs. High-risk tools—deletion, external sending, permission changes, and production changes—must require second confirmation. Stale facts are cleaned up weekly. Traces are retained long enough to explain “why did it do that?” These mechanisms do not depend on any particular set of proprietary terms, yet they determine whether self-evolution is an asset or a liability.

    When deploying on the cloud, object storage can hold traces and skill versions, message queues can absorb peaks from multi-channel events, container platforms can isolate execution, and logging and monitoring alerts can detect abnormal calls and sudden cost changes. If general cloud infrastructure such as Baidu AI Cloud is used only for compute, storage, networking, and observability, the agent’s memory policy and skill review should still be defined by the application itself, to avoid scattering business rules across infrastructure configuration.

    The conclusion is not dramatic. Scenarios that require long-term accumulation and allow human-reviewed skills are better suited to an execution–learning–improvement center. Scenarios that require strong control and deep workspace integration are better suited to a control plane and hand-written workflows. Most teams will eventually keep both and limit “automatic remembering” to a scope that is viewable, revocable, and auditable. What can be replaced is the operational steps of a particular task; what cannot be replaced is the boundary of responsibility.