Building a Local Long-Term Memory System for AI Coding Assistants on Edge Compute
This article describes a local long-term memory plugin for AI coding assistants that runs on edge compute. It covers the design goals of keeping memory on the local machine, a four-layer traceable memory architecture, the reasons for using local 7B to 9B parameter models for memory summarization instead of paid cloud APIs, and the manual steps for integrating the plugin into a highly customizable coding framework. It also notes the limitations of this initial version.
In current AI-assisted programming, large language models show strong code generation and logical reasoning. However, in complex, long-running engineering work, developers often hit a core pain point: the assistant lacks “long-term memory.” As conversations grow longer, early project constraints, personal preferences, and lessons learned from past mistakes are easily pushed out of the context window. The assistant then repeats old mistakes or drifts from the agreed direction. To address this, a local memory management approach built on a highly customizable coding framework has emerged. This article explains the design philosophy, architecture choices, and integration practice of this approach, offering a reference for developers who want assistants that understand them better the more they use them.
1. Design Philosophy: Local-First and Edge Compute
Traditional memory-enhancement approaches often rely on cloud databases or API services. This brings potential privacy risks and adds architectural complexity. The core design philosophy here is “local-first” and “edge compute driven.”
This solution works as a memory management plugin for a highly customizable coding tool. Its main goal is to automatically save content worth keeping from each session into a local memory document. This content includes final conclusions, user preferences, project-specific constraints, standard procedures, and lessons learned from pitfalls. Through conversation tracking and periodic summarization, the system keeps this long-term memory up to date. Most importantly, storage, processing, and retrieval of the memory all happen locally, which keeps the data controllable, inspectable, and private.
2. Core Architecture: A Four-Layer Traceable Memory System
To store information efficiently and retrieve it accurately, the design uses a “four-layer traceable memory system.” Although this is an initial version, the architecture is well structured and builds layer by layer:
- Immediate conversation context layer: The top layer records the currently active conversation state. It captures the latest instructions and code context and serves as the basis for real-time model reasoning.
- Short-term periodic summary layer: The system extracts and summarizes the immediate conversation at set time intervals or after a set number of turns. This layer filters out redundant chatter and ineffective attempts and keeps work records that matter at each stage.
- Long-term fact layer: This is the core of the memory system. From periodic summaries, the system distills stable “memory nodes,” such as the user’s coding habits and preferences and project architecture constraints that must not be violated. This information is kept long-term as structured or semi-structured documents.
- Source traceability layer: To prevent “memory hallucination,” where the model wrongly merges or invents memories, the design emphasizes layer-by-layer traceability. Any retrieved long-term memory can be traced back to the periodic summary that produced it, and even to the specific immediate conversation context. This keeps the information accurate and verifiable.
3. Model Selection: Why Local Small Models
Model selection is unavoidable when implementing a memory plugin. This approach strongly recommends using local small models for memory extraction and summarization, such as open-source models in the 7B to 9B parameter range loaded through a local inference framework, rather than paid cloud commercial models. This choice rests on significant cost and technical considerations.
A memory management tool works by “assembling context and prompting the model.” Each time memory needs to be updated or retrieved, the system combines the current memory context with the latest conversation fragments and sends them to the model. Because the combined content changes with each call, this pattern has a cache miss rate of nearly 100% on cloud commercial APIs.
Many commercial LLM APIs offer prefix caching discounts to reduce the cost of long-context inference. But when the input prefix cannot be reused at all, every call is billed at full input length. In long-running, high-frequency memory summarization scenarios, paid large models would lead to very high operating costs.
By contrast, modern local 7B to 9B models already perform well on specific tasks such as text summarization and information extraction. Running on edge compute, they can operate stably at near-zero marginal cost and fully meet the daily needs of memory management.
4. Plugin Integration and Configuration
Integrating this memory system into an existing highly customizable coding framework usually requires following certain engineering conventions. Manual integration involves these steps:
- Module placement: Place the memory core module, the pure function module, and the settings UI module (including frontend logic and package configuration files) in the plugin directory specified by the framework.
- Dependency mounting: So the framework’s settings UI can correctly recognize and load the plugin package structure, mount the settings module into the framework’s dependency directory. On Windows, a symbolic link command is recommended to map the plugin directory to the dependency directory. This way, only one copy of the code needs to be maintained when the plugin is updated. On other platforms, you can also copy the directory directly to the dependency path.
- Enable configuration: In the framework’s core configuration file (usually in YAML format), add the corresponding plugin ID and name declaration to register the module.
- Restart to apply: After completing these steps, restart the coding tool framework. The memory tool and its settings UI take effect automatically.
Because this coding tool can execute natural-language instructions, developers can even send these installation instructions directly to a running AI session. The assistant can then follow the steps to download, place, and enable the plugin automatically, which greatly improves integration efficiency.
5. Summary and Outlook
This memory management approach meets its goal of being functional and clearly structured in its initial version. As a “runnable and modifiable” first version, however, it has limitations. Its underlying code is based on general experience and has not yet been formally stress-tested with large amounts of long-term data. There may be room for polish in TypeScript engineering details, and the handling of memory conflicts in some edge cases still needs improvement.
Still, its core idea of local storage, edge-compute inference, and periodic traceable management offers a useful practical example for solving context forgetting in AI coding assistants. As more developers contribute and the community works together to refine code details and memory flow stability, local memory systems like this could become an essential part of professional developers’ toolchains.
