Cross-Session Memory in LLMs: Design and Risks of Growing System Prompts
This article examines the design principles behind persistent cross-session memory in large language models, based on prompt text circulating in the community. It covers why system prompts keep growing, how a memory file system can be structured with directory indexes and on-demand retrieval, what categories and metadata memory entries should include, and the privacy, permission, deletion, concurrency, and prompt-injection risks that teams must address before adopting such an architecture.
According to prompt text circulating in the community, the system prompt of a certain large model has grown from roughly 120,000 characters last month to approximately 200,000 characters. This figure comes from unofficial channels, and the counting methodology, version timing, and completeness have not been confirmed by the vendor. The following discussion focuses on the design ideas visible in the text and does not make factual judgments about any specific product.
Why System Prompts Keep Getting Longer
Prompt bloat is a direct result of patch-style maintenance. Every time a bad answer appears, a new rule is added. Every time a new tool is integrated, a section of product description and invocation specification is appended. Over time, the prompt turns into a rule compendium that is hard to read end to end.
The leaked content shows that growth is concentrated in three types of modules.
The first is tool integration and product descriptions. This covers coding tools, collaborative office suites, browser extensions, spreadsheets, presentation software, and design tools. Each tool requires invocation formats, applicable scenarios, and output specifications, and this section grows as the product line expands.
The second is safety guardrails. These include protections for minors, mental health, weapons, and cybersecurity policies, as well as jailbreak reminders in long conversations. To cover more edge cases, these rules are written with increasing granularity.
The third is language style and interaction rules, such as tone control and how multi-turn conversations should connect. Individual rules look small, but together they consume a large number of characters.
The cost of this bloat is straightforward. Every request must carry a longer prefix, which raises inference costs. Rules may also conflict with one another, and the model must locate applicable clauses within a large body of text, increasing the risk of diluted attention.
Basic Structure of a Cross-Session Memory File System
The most notable part of the leaked text is a persistent memory specification marked with <memory_filesystem>. Information written by the model during one session is saved to files and read in later sessions. This shifts the model from starting from zero in every session to being able to carry context forward.
The specification includes a clear writing principle: writing serves future sessions, regardless of whether the user has asked for it. The model therefore needs to judge which information has long-term value, such as stable identity information, decisions on long-running projects, and preferences the user has explicitly expressed. Temporary chitchat and one-off questions are usually not worth saving.
Multiple frontends may share the same set of memory files, so the specification also addresses read/write ordering, directory structure, privacy boundaries, and concurrent conflicts. If two sessions modify the same file at the same time, the system needs deterministic merge or overwrite rules. The leaked text describes these details at some length but does not provide complete implementation code. Readers should treat it as a design concept rather than an interface document that can be reused directly.
Full Injection vs. On-Demand Retrieval
Faced with growing memory, the most direct approach is to put all memory into the system prompt. This full-injection approach is simple to implement, but it quickly consumes the context window and increases interference from irrelevant information.
The leaked design uses a directory index plus on-demand retrieval. At the start of each interaction, the system injects only three types of content:
- User profile (
<profile>): the body ofprofile.md, containing basic identity information. - Preferences (
<preferences>): the user’s preferences for answer style and language. - Memory listing (
<memory_listing>): the paths, summaries, aliases, and sources of all memory files. File bodies are not injected; only paths are shown.
When the user asks a question, the model first scans the memory listing. If a file may be relevant, the model needs to call memory_read() to retrieve the body before answering. For example, if the listing contains /areas/flutter-project.md and the user asks about a previous architectural decision for a Flutter project, the model should read that file first rather than immediately saying it does not know.
The table below compares the two approaches.
| Dimension | Full injection | Directory index plus on-demand retrieval |
|---|---|---|
| Context usage | Grows linearly with memory | Mostly fixed, increases on demand |
| Information hit rate | Relevant and irrelevant information mixed together | Filter first, then read; higher relevance |
| Implementation complexity | Low | Higher; requires retrieval and read tools |
| Latency | No extra calls | Adds one tool call per read |
| Applicable boundary | Small memory volume, with most content used every time | Large memory volume, with only some content relevant to specific questions |
On-demand retrieval also has costs. If directory descriptions are inaccurate, the model may miss relevant files. Summaries and aliases in the listing therefore need careful maintenance.
Memory Categories and Field Templates
The leaked text divides memory into five major categories. Take /profile.md as an example: it stores stable identity information such as name, job title, employer, and the business lines the user is responsible for long term. The criterion is whether the information will still be valid three months later.
If you want to design a similar system yourself, you can use the following checklist.
- Identity information: name, role, organization. Long validity period; ask the user to confirm before changes.
- Preferences: answer length, language, formatting habits. Updated based on user feedback; a longer review cycle can be set.
- Projects: goals, technology choices, key decisions, and dates. Archived after the project ends and no longer automatically injected.
- People: individuals related to the user and their relationships. Record only information the user explicitly provides, and note the source.
- Topics: long-term interests or resource indexes. Check periodically and delete outdated content.
Each memory entry should ideally contain four fields: content, source (which conversation or user statement it came from), write time, and validity period. Memory without a source is difficult to assess for reliability later.
Risks and Controls
Persistent memory introduces new risks. The leaked text barely elaborates on this part, so it needs separate consideration during implementation.
Privacy risk is the most prominent. Memory files may contain names, occupations, interpersonal relationships, and even health-related information. Redact sensitive data before writing. Sensitive categories such as health, finance, and minors should not be written by default, or should be written only after explicit user consent.
Permission risk also needs control. Memory for different frontends, different users, and different projects should be isolated from one another. Tools that read memory should only access directories authorized for the current user and should follow the principle of least privilege.
Deletion and expiration mechanisms are essential. Users should be able to view, modify, and delete any memory entry, and deletion should genuinely take effect, including copies in backups. Setting expiration times prevents outdated information from influencing answers over the long term.
Concurrent conflicts need clear rules. If the same file is modified by multiple sessions at once, version numbers or append-only logs should be used to prevent later writes from silently overwriting earlier ones.
In addition, memory content is untrusted input. If text from a user or a webpage is written into memory and later injected into the prompt, it may carry instructions. When reading memory, treat the content as data rather than as instructions to execute.
Common Mistakes
The following mistakes are common when implementing this type of architecture.
- Writing unverified sources into memory without labeling them, making reliability impossible to judge later.
- Stacking rules without distinguishing which ones must apply every time and which apply only in specific scenarios.
- Memory files without permission controls, so any session can read everything.
- Not handling concurrent writes, leading to information loss.
- No deletion entry point, so users cannot correct or retract erroneous memory.
- Directory summaries that are too brief for the model to judge relevance, causing files that should be read to be skipped.
- No evaluation before launch. Prepare a set of test questions that require cross-session memory to answer, and check hit rate and misuse rate.
Recommendations for Team Pilots
If a team wants to reference this architecture, it can proceed in three steps.
Step one: split the prompt into core instructions, tool descriptions, and rule modules, and remove obvious duplication. Keep core instructions short and load tool descriptions on demand.
Step two: choose a pilot scenario with clear boundaries, such as technical decision records for an internal project. Allow only redacted project information to be written, and set explicit deletion and expiration rules.
Step three: build an evaluation set. Evaluate answer accuracy on cross-session questions, the degree of interference from irrelevant memory, and whether privacy fields are mistakenly written. After the evaluation passes, consider expanding the scope.
Underlying storage and retrieval can use general object storage, vector search, or database services. Selection should be based on the team’s existing data governance capabilities, compliance requirements, and cost.
Conclusion
System prompt bloat is the result of accumulating rule patches. Cross-session memory offers another approach: keep core instructions stable, place specific information in a manageable memory store, and control context length through indexing and on-demand retrieval. This approach has reference value, but it depends on clear categorization, strict permissions, deletable data, and continuous evaluation. Without these conditions, privacy and maintenance costs may outweigh the benefits.
