A Practical Guide to Learnable Agents: Memory, Skills, and Multi-Role Isolation

    A learnable agent should turn verified task experience into controlled memory and reusable skills, not store every conversation. This guide explains a learning loop, layered memory, skill engineering, background governance, offline evaluation, role isolation, a minimal build sequence, and acceptance checks.

    1. Start with the goal: accumulate experience, not endless chat history

    A typical conversational system relies mainly on the current context. After a session ends, user preferences, project constraints, and successful operating experience are hard to carry forward unless external storage and retrieval exist. Keeping the full history does not by itself create reliable learning: irrelevant information adds retrieval noise, outdated conclusions can affect later decisions, and unverified experience may be reused repeatedly.

    The core of a learnable agent is therefore not “remembering more.” It is a controlled process for turning experience into usable knowledge:

    Execute the task → record the outcome → extract candidate experience → verify it → update memory or skills → test it on later tasks.

    Here, “learning” usually means improving external memory, operating procedures, and policy configuration. It does not necessarily involve training model parameters. In engineering practice, the model’s own capability should be clearly separated from the persistence, retrieval, execution, and evaluation provided by the surrounding system.

    This article describes a general architecture, not the operating instructions for a specific product. Cross-session memory, automatic skill extraction, background governance, and offline optimization can be combined, but stable operation depends on the execution environment, data quality, access control, and evaluation system. A feature list alone is not enough to judge whether the system will work reliably.

    2. The learning loop: turn one success into verifiable experience

    2.1 Observe: save task evidence, not only the final answer

    Each task should produce a structured record that includes at least:

    • The user goal and explicit constraints
    • The materials, tools, and execution environment actually used
    • Key actions and their returned results
    • Task output and verification status
    • User feedback and unresolved issues

    Both successes and failures are worth retaining, but their sources must be distinguished. A successful tool call does not prove that the task goal was achieved, and an agent’s belief that an answer is correct does not mean the user accepts it.

    For a software development task, for example, recording only “the change is complete” is insufficient. The record should also show which checks passed, which checks were not run, and whether environmental limits applied. That evidence is what later skill extraction can rely on.

    2.2 Extract: separate facts, preferences, and procedures

    After a task, three kinds of candidate information can be extracted from the record:

    • Stable facts, such as a project’s directory conventions and delivery standards
    • User preferences, such as wanting the conclusion before the supporting explanation
    • Reusable procedures, such as how to locate a particular class of input-validation problem

    Not everything should be kept long term. Temporary access credentials, one-off debugging output, speculative conclusions, and complete sensitive documents should not enter long-term memory directly. Candidates should pass sensitive-content checks, duplicate detection, and a credibility assessment.

    2.3 Verify: place a threshold between candidates and formal knowledge

    Newly extracted experience should enter a candidate area first. The verification method then depends on risk:

    • Expression preferences can take effect after explicit user confirmation.
    • Project facts should be checked against current files or authoritative sources.
    • Operating procedures should be validated in a test environment or through task replay.
    • Procedures involving deletion, publishing, or permission changes should require human approval.

    Automation is suitable for generating candidate experience. It should not be treated as permission to publish every piece of experience unconditionally.

    2.4 Apply: retrieve for the current task instead of injecting everything

    At the start of a new session, identify the task type and role before retrieving relevant memory and skills. Retrieved results should also be filtered by validity period, source, and permissions.

    This prevents a design task from carrying internal configuration that belongs to a software-development role, and it reduces the chance that irrelevant history consumes context. The value of an experience depends on whether it applies to the current task, not merely on whether it was saved before.

    3. Layered memory: manage context, facts, and experience separately

    A practical memory architecture can be divided into four layers. These are engineering responsibilities, not names that every implementation must use.

    3.1 Working memory

    Working memory holds the current task’s goal, constraints, temporary analysis, and intermediate results. Its lifetime is usually bound to a session or task.

    Its length must be controlled. During a long task, periodically create a state summary that preserves confirmed conclusions, unfinished items, and references to key evidence, rather than repeatedly carrying the full history. A summary can omit details, so important execution logs should still remain in external records.

    3.2 Episodic memory

    Episodic memory records concrete task experiences: why a particular change failed, how a research task filtered sources, or how a design task established its constraints.

    It is mainly used for tracing and analogy. Retrieval should consider not only text similarity, but also whether the task goal, environmental conditions, and outcome are similar. Two tasks that look alike on the surface may not support the same method because their permissions or dependencies differ.

    3.3 Semantic memory

    Semantic memory stores relatively stable facts, rules, and preferences, such as project structure, terminology, and team review requirements.

    Important records should include their source, confirmation time, and scope. Facts that may change need a review mechanism. When information conflicts, the system should not simply overwrite the old record; it should compare the strength of the evidence and the conditions under which each item remains valid.

    3.4 Procedural memory

    Procedural memory carries reusable operating procedures—skills. It describes the conditions under which a class of task should be performed and how to perform it, rather than merely storing a past answer.

    A skill needs trigger conditions, input requirements, execution steps, success criteria, and failure handling. Without these elements, a procedure is difficult to reuse safely.

    4. Skill engineering: from experience notes to controlled execution units

    4.1 A skill description should cover the full execution boundary

    The following is a generic structural example. Its fields explain the design idea and do not represent the interface of any existing system:

    1. Skill name: Fix an input-validation issue
    2. Applicable conditions: A reproducible problem description and the corresponding code are available
    3. Input requirements: Expected behavior, actual behavior, and the permitted scope of changes
    4. Execution steps:
    5. 1. Build a minimal reproduction
    6. 2. Locate the validation boundary
    7. 3. Make the smallest necessary change
    8. 4. Add checks for valid and invalid inputs
    9. 5. Summarize the verification results
    10. Success criteria: The relevant checks pass and no new regression is found
    11. Failure handling: Stop expanding the change and report the blocking point
    12. Permission boundary: Do not read unrelated credentials and do not publish directly

    A skill’s usefulness does not depend on how long its description is. It depends on whether the description clearly constrains execution and provides a result that can be checked.

    4.2 Automatic generation should use a draft mechanism

    When a procedure appears across multiple tasks and has reliable outcome evidence, a skill draft can be generated. One success is usually not enough to prove general validity.

    A draft should be checked for environment-specific paths, temporary state, and sensitive information. It should also state which steps can be parameterized and which preconditions cannot be omitted. High-risk procedures should be reviewed by a person first. Low-risk procedures can be opened gradually after offline testing.

    4.3 Skills need versions and retirement states

    A skill update can introduce regressions, so versions, reasons for change, and evaluation records should be retained. A formal skill should at least distinguish candidate, enabled, disabled, and archived states.

    If a new version raises the failure rate, the system should be able to restore the previous version. Before deleting a skill, check whether other procedures depend on it, so that removing apparent redundancy does not break existing tasks.

    5. Background governance: remove redundancy without looking only at usage count

    As a skill library grows, duplication, overlapping scope, and broken environmental dependencies become likely. Background governance should judge candidates across several dimensions:

    • Whether another skill solves the same problem
    • Recent usage and actual success records
    • Whether there is clear evidence of failure
    • Whether the skill involves high-risk operations
    • Whether other tasks or skills depend on it

    Text similarity can help find possible duplicates, but it does not prove that two skills can be merged. Procedures may have similar steps while having different permission boundaries—for example, one may be limited to read-only checks while another performs writes.

    A safer governance flow is to identify candidates, analyze their differences, propose a merge or retirement, run regression evaluation, and keep a rollback record. A low-frequency but critical recovery procedure should not be deleted merely because it has not been used recently.

    6. Offline evaluation and iterative optimization: improvement needs a baseline

    Offline optimization generates candidate policies without affecting live tasks and compares them on a fixed task set. The optimization target may be skill steps, retrieval rules, or task-planning methods; it does not have to be model parameters.

    The evaluation set should include normal tasks, boundary tasks, and failure cases. It should also be appropriately separated from the samples used to generate the candidate policy, so the result is not valid only for cases already seen.

    Useful measures include:

    • Whether the task goal was achieved
    • Whether the output satisfies explicit constraints
    • Whether tool calls were correct and necessary
    • Whether unauthorized access, sensitive-information exposure, or incorrect writes occurred
    • Whether execution time and resource consumption were reasonable
    • Whether performance is stable across similar tasks

    An aggregate score is not sufficient. Even if a candidate improves the average completion rate, it should not be released directly if it introduces a serious safety problem.

    Offline results still require online validation. Before formal enablement, a candidate can be limited to generating recommendations without executing them, or it can be used only for low-risk tasks. New failures found in real use should return to the evaluation set, forming a continuous loop.

    7. Isolated deployment for three roles: isolation is more than different prompts

    Software development, in-depth research, and design can share underlying capabilities while having different working boundaries.

    7.1 Software-development role

    This role mainly analyzes code, implements changes, and verifies them. It may access a specified project directory and the necessary execution environment, but reading unrelated files and credentials should be restricted. Publishing, deleting important data, and changing permissions require separate authorization.

    Its skill library should emphasize problem reproduction, minimal changes, regression checks, and change explanations.

    7.2 In-depth research role

    This role mainly decomposes questions, analyzes sources, and synthesizes evidence. It should record sources and retrieval times, and distinguish facts, inferences, and judgments that still need verification.

    Research notes should preserve key supporting evidence, not only a summary of the conclusion. Conflicting sources should be presented with the conditions of the conflict rather than automatically removing differences to force a single answer.

    7.3 Design role

    This role mainly clarifies requirements, organizes proposals, and maintains delivery standards. Its long-term memory can store confirmed visual preferences, layout principles, and accessibility requirements.

    Temporary options from an exploration phase should not be frozen directly as long-term preferences. Publishing externally or overwriting official assets should require a confirmation step.

    7.4 Real isolation requires resource boundaries

    If the goal is complete isolation among the three roles, configure each of the following separately:

    • Session identifiers and message entry points
    • Working directories and runtime identities
    • Memory storage and retrieval scope
    • Skill libraries and credentials
    • Logs, backups, and access permissions

    Using different role prompts alone does not constitute isolation. Application-level checks can reduce misuse, but process, storage, and permission boundaries matter as well. Whether material should be shared depends on the task. Shared material should be provided through an explicitly authorized read-only area rather than by opening all storage.

    8. Build from scratch: close a minimal loop before automating further

    First, define each role’s task scope, accessible resources, and operations that require confirmation, and turn them into an explicit permission list.

    Second, create separate workspaces, memory areas, and skill areas. Confirm that read and write scopes are correct before connecting automatic retrieval.

    Third, complete basic task execution and structured logging. Automatic skill extraction can remain disabled while you confirm that results are traceable.

    Fourth, add candidate-memory extraction and an approval mechanism. Only information that is explicit, necessary, and verifiable should be stored long term.

    Fifth, manually create a small number of high-value skills, including trigger conditions, success criteria, and failure handling.

    Sixth, prepare normal, boundary, and failure test samples, and verify that memory retrieval and skill execution are stable.

    Seventh, gradually enable skill-draft generation, duplicate detection, and retirement suggestions while retaining version rollback.

    Eighth, configure separate message entry points for the three roles and check message routing, identity verification, and attachment permissions so tasks do not enter the wrong role.

    These are implementation stages, not a promise about deployment duration. Actual time depends on the execution environment, permission requirements, and integration complexity. Local execution also does not necessarily mean that all data remains on the machine. If inference or retrieval depends on an external service, the data flow and access policy still need to be confirmed.

    9. Acceptance criteria: remember accurately, apply correctly, and roll back

    Before release, verify at least three areas.

    Memory accuracy: A new session can retrieve confirmed preferences; expired facts do not continue to influence decisions; and roles cannot access one another’s memory without authorization.

    Skill reliability: Normal tasks can be completed; execution stops when a precondition is missing; failures are reported with their cause; and a disabled skill is no longer called.

    Safety and recovery: Sensitive information does not enter ordinary memory; high-risk operations require confirmation; a failed candidate policy can be rolled back; and logs can trace the basis of key actions.

    The value of a learnable agent is not a continual increase in the number of memories and skills. It is the conversion of verified experience into reliable capability. Only when the learning loop, knowledge governance, offline evaluation, and resource isolation are designed together can the system reduce repeated work over long-term use while keeping behavior explainable, permissions controllable, and errors recoverable.