Memory and Skill Evolution for Plugin-Based AI Agents

    This article explains how to structure plugin-based AI agents so that experience accumulates instead of evaporating. It covers a closed-loop learning cycle of plan, execute, verify, and distill; a four-layer memory design spanning session, preference, procedural, and factual memory; the boundaries that keep skill self-evolution auditable and versioned; how to organize native tools, switch models, and connect external knowledge; how scheduled runs and subagent collaboration should be scoped; and the engineering constraints around permissions, logging, observability, and rollback. It is aimed at teams building long-running, repetitive, structurally stable agent workflows.

    A plugin-based agent is a good fit for the split between “who decides once a message arrives” and “who actually does the work.” The access layer handles channel adaptation, session routing, and scheduling policy. The execution layer calls tools, decomposes steps, records what happened, and distills successful paths into reusable skills. The two layers meet at an explicit task contract: the input is a goal, constraints, and context; the output is a result, supporting evidence, and a traceable execution trail. This avoids both piling all logic into a single chat window and running executions that cannot be reused.

    1. What closed-loop learning actually solves

    Failures in long-horizon tasks rarely come from a single bad inference. They come from lost context, steps that cannot be reproduced, and experience that does not transfer. Closed-loop learning splits a task into four stages: plan, execute, verify, and distill. The planning stage defines the success criteria and the stop conditions. The execution stage performs only observable tool calls. The verification stage checks the result against those criteria rather than trusting the model’s own account of what it did. The distillation stage extracts stable steps into a skill and leaves unstable factors in the context of that single run.

    Verification must be independent of generation. For file-processing tasks, check that the artifact exists, that its format matches the agreement, and that key fields are present. For code tasks, at minimum run a static check or a minimal test. For retrieval tasks, keep the cited sources. When verification fails, go back to planning instead of extending an incorrect result. That way memory stores verified methods rather than a polished version of a failed path.

    2. Designing layered memory

    Memory should not be an infinitely growing conversation log. A coarse layering similar to human cognition works, as long as the implementation stays explainable:

    1. Session memory: the current task’s goal, constraints, attempted steps, and intermediate artifacts. It can be archived or discarded when the task ends.
    2. Preference memory: stable formatting, naming, approval habits, and prohibitions for a user or team. It changes rarely and must be manually editable.
    3. Procedural memory: the trigger conditions, step skeleton, required tools, and failure fallbacks for a class of tasks. This corresponds to the skills described below.
    4. Factual memory: verifiable information such as project paths, environment differences, and interface contracts. Every entry must carry a source and an update time, and stale entries are down-weighted.

    On retrieval, match procedural memory by task type first, then match factual memory by entity, and finally apply preferences to shape the output. Before writing, run deduplication and conflict detection: when the same key has contradictory values, keep the newer update time and its evidence instead of silently overwriting. Sensitive fields are excluded from storage by default, or stored as references rather than raw text.

    The structure can be plain. What matters is that the fields are auditable:

    1. skill:
    2. name: periodic report consolidation
    3. trigger: scheduled time reached and new files present in input directory
    4. steps:
    5. - validate file list and fields
    6. - aggregate using the agreed template
    7. - generate a diff summary
    8. tools: file read, spreadsheet processing, result delivery
    9. checks: row count matches, required columns non-empty, artifact opens

    3. The boundaries of skill self-evolution

    A skill is a structured process, not an unreviewable block of prompt text. After a complex task completes, abstract only the steps that recurred and passed verification: trigger conditions, inputs and outputs, tool dependencies, checkpoints, and known failure modes. When a similar scenario appears again, invoke that skill and revise its checkpoints using the new failure samples, rather than planning from scratch every time.

    Evolution needs a threshold. A single success is not enough to admit a skill. If the steps depend on a temporary path, a one-time credential, or someone’s personal desktop layout, they should not be promoted to a team skill. Revisions are versioned: a new version is validated in parallel while the old one remains rollback-able. Skill files live somewhere reviewable, and changes go through a review process close to that of code, so the executor cannot rewrite a production flow unnoticed.

    4. Tools, models, and external knowledge

    The execution layer needs a set of clearly scoped native capabilities: file read/write, retrieval, code execution, browser or page fetching, scheduled triggering, and result delivery. Quantity is not the goal; coverage and permission boundaries are. Each tool declares its input schema, side effects, and timeout. Read-only queries and operations that mutate the environment are authorized separately.

    Models can be switched per task: use models strong at long context for planning and summarization, and smaller, more stable models for format conversion and classification. When switching, keep the same tool schemas and memory interfaces so that changing models does not change a set of implicit conventions. External knowledge is connected through a standard retrieval protocol, and returned fragments must carry provenance; when the agent cites knowledge, it keeps the link or document identifier so a human can re-check it. Do not write retrieval results directly into long-term factual memory unless they have been verified.

    5. Scheduled tasks and subagent collaboration

    Scheduled tasks are triggered by a scheduler, not by whether some conversation happens to still be open. Each run carries its own run identifier, an input snapshot, and a budget (time, steps, number of external calls). On timeout or step exhaustion, stop and leave a breakpoint so the next run resumes from the checkpoint instead of repeating all side effects.

    Complex tasks can be split across parallel subagents, but the unit of splitting should be a sub-goal that can be verified independently, such as “collect materials,” “draft,” or “review against the spec.” The parent agent owns only the task graph, dependencies, and aggregation; it does not micromanage inside a subagent. Subagents do not share writable memory; they read only the context the parent passes down, and any write-back must pass the parent’s schema validation to prevent parallel writes from overwriting each other. Steps with dependencies stay sequential — for example, obtain the list before aggregating.

    6. Engineering constraints in production

    A plugin should be explicitly installed on first enablement and declare its minimum runtime, so a silent upgrade cannot change tool behavior. Permissions follow least privilege: read more, write less; writes are auditable; outbound sending requires a second confirmation or an allowlist. Logs record the goal, tool name, a parameter summary, and the verification outcome — never secrets or full private text.

    For observability, track at least four metrics: task completion rate, verification failure rate, human takeover rate, and skill reuse rate. Accumulation is working only when reuse rises while failure rate does not. If skills multiply and takeovers multiply with them, the abstraction happened too early or the checkpoints are too loose. Write the rollback strategy in advance: disable a skill, revert to the previous memory snapshot, pause scheduled tasks.

    The fit is long-horizon, repetitive, structurally stable work: organizing materials, periodic reports, editing documents to a spec, multi-step data reconciliation. Open-ended creative work and high-risk irreversible operations are not suited to a fully automatic closed loop; constrain the agent to drafts and checklists and let a human make the final call.

    Separating access, decision, and execution, carrying experience in verifiable memory and versionable skills, and raising throughput with limited tools and parallel subtasks are the basic conditions for a plugin-based agent to keep improving. Without verification and permission boundaries, so-called self-evolution only accumulates side effects that nobody can explain.