AI Agent External Memory Design: Improving with Use Without Retraining

    Learn how external memory, reusable skills, and a domain wiki can help AI agents improve with use while keeping model weights fixed. This article covers file-based state, a closed-loop learning workflow, terminal-first tooling, and controls for versioning, permissions, privacy, and evaluation.

    1. Why Improving with Use Should Not Depend on Model Retraining

    A common misconception about agent evolution is that becoming more capable requires changing model weights. For most personal and enterprise use cases, updating a foundation model through everyday use is neither practical nor easy to control. Training is expensive, update cycles are long, and changes can introduce catastrophic forgetting or unpredictable behavioral drift.

    A more practical approach starts with a simple distinction: model parameters may be fixed, but the agent system is not. An agent’s behavior depends on both the model’s capabilities and its external context. By storing user preferences, task context, and reusable methods in editable structures outside the model, an agent can become better adapted to its users without changing its weights.

    This shifts the focus:

    • From the model as the product to the system as the product.
    • From training-data-driven improvement to runtime-context-driven improvement.
    • From opaque memory to transparent, auditable, version-controlled state stored in files.

    The immediate benefit is control. Learned information exists as human-readable text that can be reviewed, rolled back, branched, and merged. When something goes wrong, developers can trace it to a specific memory entry or skill rather than an unexplained change in model weights.

    2. Separate Agent State into Three Types of External Files

    A mature agent designed to improve through use typically separates its external state into three categories: memory, skills, and a wiki.

    Memory: Personal and Task Context

    Memory provides continuity. A useful distinction is between a long-term user profile and a task workspace:

    • User profile: Language preferences, coding style, frequently used technology stacks, and communication habits are suitable for long-term retention.
    • Task context: The current problem, constraints, interim conclusions, and outstanding actions can be archived or summarized when the task ends.

    For this file-based approach, Markdown is a useful choice over database records or binary formats. Plain text supports diffs and code review, integrates naturally with version control, and lets people directly correct an agent’s mistakes.

    Memory can be organized into structured sections:

    1. # User Preferences
    2. - Coding style: Explicit type annotations; line width of 100
    3. - Technology stack: Python 3.11 + FastAPI
    4. # Long-Term Facts
    5. - Production uses containerized deployments
    6. - Reply in Chinese while retaining English technical terms

    Skills: Reusable Methods

    Skills turn lessons learned into operational playbooks. When an agent discovers an effective workflow—for example, running a particular set of checks before deployment—it should capture that workflow in a skill document rather than rediscover it during the next task.

    A skill document should describe its applicable scenarios, prerequisites, steps, common pitfalls, and ways to avoid them. Key design principles include:

    • Store each skill in a separate file and load it only when needed to avoid bloating the context.
    • Use natural language so both people and models can understand it.
    • Follow an open standard format, such as the Agent Skills specification, to support portability across tools.
    1. # Skill: Investigating API Performance Issues
    2. ## When to Use
    3. API P95 latency has risen significantly without errors.
    4. ## Steps
    5. 1. Check the time distribution of slow-query log entries.
    6. 2. Compare changes in the cache hit rate.
    7. 3. Inspect connection pool wait metrics.
    8. ## Known Pitfalls
    9. - Connection pool settings may not have taken effect after a container restart.
    10. Verify the active configuration.

    Wiki: Domain Knowledge

    The wiki holds knowledge that is independent of a specific task but closely tied to the business domain: glossaries, architecture decision records, internal processes, and compliance requirements.

    The distinction is straightforward:

    • Memory answers: Who is the user, and what are they working on?
    • Skills answer: How should this type of task be performed?
    • Wiki answers: How does this domain operate?

    These boundaries should remain clear. Otherwise, memory becomes bloated, skills are duplicated, and the wiki falls out of date.

    A simple classification rule is:

    • Personal or project facts that should survive the session → Memory
    • Operational experience reusable across tasks → Skills
    • Relatively stable domain facts shared by multiple people → Wiki

    3. Build a Closed-Loop Learning Workflow

    External files are only containers. The essential component is the loop that moves useful knowledge into those files and applies it later.

    A complete learning loop has four stages:

    1. Observe: Identify information worth retaining during task execution, such as user corrections, failed attempts and retries, or newly discovered constraints.
    2. Distill: Compress raw interactions into concise, actionable entries rather than copying noise into long-term state.
    3. Write: Store each entry in memory, a skill, or the wiki, with a timestamp and source information.
    4. Retrieve and apply: At the start of subsequent tasks, retrieve relevant entries based on the current context and include them in the prompt.

    Retrieval can combine full-text indexing with semantic search. Full-text indexing supports exact matches, such as project names or error keywords. Semantic search supports less precise requests, such as “a similar deployment problem we encountered before.” Historical conversations should also remain searchable as a fallback knowledge source.

    Noise control is equally important. Set criteria for writing new entries and define deduplication rules. Only capture experience as a skill after it has been shown to work. Merge similar memory entries, and have the agent periodically review its state and archive outdated content.

    4. Provide a Terminal-First Engineering Workflow

    The terminal is a common interface for agents that improve through use because it fits naturally into developers’ workflows. A capable agent workbench should provide:

    • Multiline editing and command completion for working with long prompts.
    • Persistent conversation history and full-text search.
    • Streaming output and interruption controls to keep long-running tasks manageable.
    • Basic capabilities such as file access, command execution, and tool invocation.
    • Cross-platform support and standardized installation to reduce team adoption overhead.

    The model integration layer should remain open. Supporting multiple model providers and OpenAI-compatible interfaces lets teams switch models according to task complexity, cost, and latency.

    External state should remain decoupled from the model, so changing models does not mean losing memory.

    5. Implementation Recommendations and Risk Controls

    Put All State Under Version Control

    Create dedicated repositories or directories for memory, skills, and the wiki, and manage them with Git. Every change representing an agent’s “learning” should be traceable.

    Define Read and Write Permissions

    Explicitly configure which files the agent may update automatically and which require human approval. Lessons involving production operations should undergo human review before being formalized for reuse.

    Manage the Skill Lifecycle

    Mark new skills as draft. Promote them to stable after successful reuse and validation. Periodically remove skills that have gone unused for a long time.

    Address Privacy and Compliance

    Memory may contain sensitive information. Define retention periods, access controls, and export and deletion mechanisms. Enterprise deployments should integrate these operations with centralized audit logging.

    Evaluate Whether the Agent Is Improving

    Maintain a benchmark task set and periodically compare performance with and without external state. This verifies that the learning loop is producing value rather than merely accumulating noise.

    6. Conclusion

    Building an agent that improves with use does not have to mean training a larger model. A practical alternative is to externalize learning into a transparent file-based system:

    • Memory preserves personal and task context.
    • Skills capture reusable methods.
    • A wiki maintains domain knowledge.
    • Retrieval and writing mechanisms connect them into a closed loop.

    The model’s weights stay fixed, while the system’s behavior becomes more refined through use. For developers, mastering external state design and closed-loop learning can be more valuable than chasing each new model release when building stable, auditable agents that become better adapted to everyday work.