AI Agents That Get Smarter with Use: Engineering Practices

    This article explains how to build an auditable experience loop for conversational AI agents through persistent memory, reusable skills, and cross-session retrieval. It covers what to store, when to promote experience into memory or skills, how the three layers work together, and how to manage risks such as stale knowledge, privacy exposure, skill misuse, and unbounded growth.

    Why “Resetting Every Time” Holds Agents Back

    A common failure in conversational agents is not only that the model is insufficiently capable. It is that session boundaries cut off experience. A user has just explained the directory structure, release window, and code style, and then has to explain them again in the next turn. A dependency conflict that was already resolved last week becomes a new round of searching and trial and error this week. For developers and enterprise users, this creates three direct costs: repeated communication lengthens task time, error paths are executed repeatedly, and tacit knowledge held by an individual or team cannot enter the system.

    “Getting smarter with use” does not mean online self-training of model weights. It means building an auditable experience loop at the application layer: write stable facts into memory, distill reusable solutions into skills, and leave raw conversations available for retrieval. The three have different roles and cannot replace one another. Memory answers “who this person and this project are”; skills answer “how this type of problem was solved successfully last time”; retrieval answers “what the raw context was at the time.”

    Loop 1: Persistent Memory That Stores Only Reusable Facts

    Persistent memory is suitable for information that remains true across sessions and affects later decisions. Typical content includes work preferences, common command conventions, repository and environment background, review criteria, and prohibited actions. It is not suitable for one-off error stacks, unverified guesses, keys and tokens, or complete chat logs.

    For engineering purposes, it is better to split memory into two logical documents rather than piling everything into one endlessly growing text blob.

    • User profile: role, communication preferences, common technology stack, and output format requirements. It answers “how to work with this person,” not “this person’s entire private life.”
    • Working memory: current project goals, module boundaries, confirmed constraints, to-dos, and rejected options. When the project switches or a phase ends, these items should be archived or downweighted to avoid old project facts contaminating new tasks.

    Writes should be proactively proposed by the agent and committed through rules or human confirmation. Recommended triggers are: the user explicitly says “do it this way from now on,” the same preference appears repeatedly across multiple tasks, or a constraint would cause rework if forgotten. Each write should include time, source session, and confidence. Expired information should be overwritten rather than appended; otherwise, old and new conclusions will both be retrieved.

    When loading memory, do not stuff all of it into the context. First filter by topic for the current task, then limit the number of entries and words. Memory is part of the prompt, and excessive memory crowds out actual code and logs. For critical constraints, require the model to explicitly reference them during planning so that it is easy to check afterward whether the memory was actually used.

    A schematic memory entry does not need to be tied to any specific product, as long as the structure is stable:

    1. id: pref-review-style
    2. scope: user
    3. statement: In code reviews, list risks first, then suggest changes; avoid empty praise
    4. source: User repeatedly confirmed during release reviews
    5. updated_at: 2026-03-01
    6. confidence: high

    Loop 2: Skill Distillation That Turns Successful Paths into Callable Procedures

    Complex tasks often span multiple tools: reading code, checking logs, changing configuration, running tests, and summarizing differences. If only the final answer is retained, the next run still requires exploration from scratch. The value of a skill system is to distill the solution approach into a reusable procedure when a task succeeds and its steps are complex enough.

    A qualified skill should include at least: applicable scenario, preconditions, step order, required inputs, success criteria, and known failure modes. It should describe “how to judge, how to act, and what counts as done,” rather than paste a complete log from one run. The number of tool calls can be a signal that distillation is warranted, but it is not sufficient. Five aimless trials are not worth saving; a stable, verifiable path completed within three steps is more worth saving.

    Skills should be versioned. Once the environment, dependencies, or interfaces change, old steps become incorrect shortcuts. Record the runtime assumptions applicable to each skill, and when it fails, lower its priority or mark it for revision instead of continuing to apply it automatically. Before reuse, perform a lightweight match: whether the task type, technology stack, and constraints are consistent. If they do not match, fall back to normal reasoning and avoid “using a skill for the sake of using a skill.”

    The boundary between skills and memory should be clear. Memory is fact: “the release window is Tuesday.” A skill is method: “how to complete a configuration change without interrupting traffic.” Writing methods into memory makes prompts confusing, while writing facts into skills makes skills hard to transfer.

    Loop 3: Cross-Session Retrieval That Preserves Raw Evidence

    Memory and skills are compressed conclusions, and compression inevitably loses detail. Historical conversations should therefore remain in local or controlled storage, with full-text search supporting review by keyword, time, and project. When uncertain, an agent can first retrieve how a similar issue was handled three months ago, then decide whether to follow that approach.

    A retrieval system must solve four problems.

    1. What to index: user goals, key errors, final conclusions, and involved module names. The full text can be retained, but snippets shown to the model should be truncated and include their source.
    2. How to rank: recency, keyword relevance, and whether an item is marked “verified.” Pure relevance can easily rank incidental mentions first.
    3. How to cite: distinguish “retrieved history” from “current inference” in answers, and avoid presenting an old solution as if it had been verified again.
    4. How to forget: delete or de-identify data according to retention period, project archive, and sensitivity level. The stronger the retrieval capability, the less acceptable it is to store keys and personal information in plaintext for long periods.

    Full-text search engines, local databases, object storage, and logging services are only implementation mechanisms. When choosing among them, consider whether data needs to leave the local machine, whether multi-device synchronization is required, and whether auditing is needed. There is no need to synchronize all conversations to an uncontrolled location just to make them searchable.

    How the Three Loops Form Self-Improvement Without Unbounded Growth

    The correct order of the loop is: execute the task, validate the result, and then decide what to write. An unverified plan should not be promoted to a skill; a single slip of the tongue should not be promoted to a user preference. A simple state machine can help:

    • Observe: extract candidate facts, candidate steps, and candidate evidence from the current conversation.
    • Validate: tests pass, the user confirms, or the item is consistent with existing constraints.
    • Write: facts go into memory, procedures go into skills, and raw text goes into the retrieval index.
    • Reuse: next time, retrieve evidence first, then load relevant memory, and finally decide whether to invoke a skill.
    • Decay: entries that are unused for a long time, misused multiple times, or belong to a completed project are downweighted or archived.

    Without decay, the system becomes “dumber with use”: stale preferences override new requirements, skill sprawl slows matching, and retrieved snippets contradict one another. The metric for improvement should also not be the number of memory entries, but a decrease in repeated explanations, a decrease in the number of steps for similar tasks, and a decrease in rework rate.

    Risks and Acceptance in Production

    This design is easily misunderstood as the model learning by itself. In reality, model weights usually remain unchanged; what changes is external state. Three types of risk must therefore be prevented.

    • Error fossilization: once a hallucination is written into memory, it is reinforced across subsequent sessions. Countermeasures include source tags, human confirmation, and rollback.
    • Privacy and permissions: the visibility of user profiles and working notes should be isolated by person or project, with least privilege by default. De-identification is required before sharing across team members.
    • Skill misuse: scenarios may be similar but constraints different, for example, read-only troubleshooting versus directly changing production. Skill descriptions should state prohibited actions.

    Acceptance can be concrete: for the same user’s second similar task, the system should automatically include confirmed preferences; for a problem covered by a distilled skill, the plan should cite that skill instead of searching from zero; for a vague recollection, retrieval should return snippets with source and time and allow the model to say “the historical solution needs revalidation.”

    When deployed on cloud infrastructure, object storage can hold archived conversations, logs and monitoring can record writes, hits, and failures, and container platforms can run isolated agent processes. These are general capabilities and do not depend on any proprietary interface. If you use general cloud resources such as Baidu AI Cloud, the focus should still be permissions, retention periods, and auditing rather than binding the loop itself to a specific model or console path.

    Conclusion

    Whether an agent becomes smarter through use depends on whether experience is classified, validated, and reversibly stored. Persistent memory handles stable facts, skills handle reusable procedures, and cross-session retrieval handles raw evidence. Once the three form a loop, the system no longer resets every time; without validation, boundaries, and decay, the same mechanism only accumulates noise. For teams, defining clearly “what to write, when to write it, and how to prove it is still correct” has more long-term value than pursuing a longer context.