# Long-Term Memory AI --- --- > What long-term memory means for AI agents, how it differs from the context window, and how Glen keeps a team's agent memory durable over months. --- --- # Long-term memory for AI agents, and what keeps it useful over time URL: https://longtermmemoryai.dev/ Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > Long-term memory for AI is any knowledge that outlives a single conversation and is put back into the model's context when a later task needs it. Models keep nothing between sessions on their own, so durable memory lives outside the model: in instruction files, in machine-local notes, or in a shared store such as Glen, which records coding-agent sessions for a whole organization and recalls the matching part when new work touches it. ## What counts as long-term memory for an AI A language model's weights hold what it absorbed in training. They do not change while you work with it. Everything it knows about your codebase, your team or yesterday's bug has to be in the context window for the current call, and that window is emptied when the session ends. So long-term memory is a retrieval problem. Something has to write knowledge down while work happens, keep it somewhere that survives restarts and laptop changes, and hand the right slice back to the model at the right moment. Memory here is context, not weights: nothing is retrained. *Where an AI coding agent's knowledge can live* | Place | How long it lasts | Who changes it | Example | | --- | --- | --- | --- | | Model weights | Until the vendor ships a new model | The model vendor | How Python's `asyncio` works | | Context window | One session | Every turn | The file the agent just opened | | Instruction files | As long as someone maintains them | People, through git | `AGENTS.md`, `CLAUDE.md`, Cursor rules | | Machine-local memory | Until you change machines | The agent, as it works | Claude Code auto memory, Codex memories | | Shared memory store | Across sessions, machines and people | Recorded from real work | Glen | ## Four reasons durable memory is hard Saving text is easy. Keeping a memory that is still worth reading six months later is the hard part, and it fails in predictable ways. *Failure modes of long-term AI memory, and Glen's handling* | Problem | What goes wrong | How Glen handles it | | --- | --- | --- | | Staleness | A fact that was true in March is recalled in September with the same confidence | `glen forget` stops a memory being recalled; `glen restore` brings it back if that was a mistake | | Contradictions | The team reversed a decision, and both versions sit in memory | Glen aims to follow the decision that stuck. The old one can still surface, so forgetting it is one command | | Access control | A shared memory leaks something a person was never cleared to see | Checks run per memory at recall, so an agent only surfaces what its user can already see. No data crosses organizations | | Growth | Memory grows faster than any context window, so loading all of it is impossible | Recall picks the memories that match the current prompt, not the whole store | ## How Glen gives coding agents long-term memory [Glen](https://tryglen.com) installs a plugin into each coding agent you use. The plugin's hooks call the `glen` CLI on every turn, so capture does not depend on the model deciding something is worth saving. Turns from you and your teammates go into one hosted memory that belongs to the organization rather than to any laptop. Recall depends on what the agent's hooks allow. Claude Code, Codex and Pi get matching memories added to context before the model reads the prompt. Cursor and Grok Build can't take context from a hook, so their bundled rule tells the agent to run `glen search` when a task touches past work. > **Give your agents memory that lasts past the session** Install once, and every turn your team's agents take becomes something a later session can recall. Free for up to 3 people. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## What long-term memory should not replace A rule that must apply on every task, such as the test command or a file nobody may edit, belongs in `AGENTS.md` or `CLAUDE.md`. Those files load every session without the agent having to search. Recalled memory suits the reasoning behind past changes. For the split between in-session and durable memory, see [short-term vs long-term memory](https://longtermmemoryai.dev/short-term-vs-long-term); for how the kinds of memory map onto an agent, see [episodic, semantic and procedural memory](https://longtermmemoryai.dev/types-of-memory). The model-side view is covered in [how LLM memory works](https://llmmemory.dev). ## Frequently asked questions ### Does AI have long-term memory? Not inside the model. A model forgets everything when a session ends, so long-term memory is a store outside it that writes down past work and loads the relevant part into context later. ### How do AI agents remember things long term? Through files that load every session (AGENTS.md, CLAUDE.md), notes the agent writes on one machine, or a shared memory such as Glen that records sessions and recalls them by relevance. ### Is long-term AI memory the same as fine-tuning? No. Fine-tuning changes model weights. Glen changes nothing in the model; it puts recalled memories into the context window, and Glen does not train models on customer content. ### Can AI memory go out of date? Yes, and that is the main risk of keeping it. Glen aims to recall the decision that stuck after a reversal, and glen forget removes a stale memory from recall without deleting it for good. --- # Short-term and long-term memory in AI agents URL: https://longtermmemoryai.dev/short-term-vs-long-term Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > Short-term memory in an AI agent is its context window: the prompt, files and tool output it can see right now, gone when the session ends. Long-term memory is stored outside the model and survives across sessions, machines and people. A useful setup moves knowledge between them on its own: written down as each turn finishes, and read back when a later prompt needs it. ## Short-term memory is the context window Everything an agent reasons over in a session sits in its context window: your prompt, the files it read, the commands it ran and their output. The window is large but finite, and agents compact or drop older turns as it fills. When you close the session, all of it is gone. Engineers notice this most on long tasks. An agent figures out on turn 12 that a test is flaky because of a shared fixture, then on turn 80, after a compaction, rediscovers it from scratch. Next morning's session never knew. ## Long-term memory sits outside the model *Short-term and long-term memory in an AI coding agent* | | Short-term (context window) | Long-term (memory store) | | --- | --- | --- | | Lifetime | One session | Months, across sessions | | Scope | One agent, one task | One person, or a whole organization | | Size limit | The model's context length | Bounded by storage, not by the model | | What gets in | Whatever the agent reads this session | What was recorded or written earlier | | Cost | Tokens on every turn | A lookup, plus tokens for what is recalled | The built-in long-term layers are deliberately small because they load whole. Claude Code's auto memory loads the first 200 lines or 25 KB of its index per session, and Codex reads `AGENTS.md` files up to 32 KiB by default. Both live on one machine or in one repo. ## Moving knowledge from one to the other The interesting part is the hand-off. If writing to long-term memory waits for the model to decide something matters, most of the session is lost. If reading waits for the model to think of searching, memory stays unused. 1. **At the end of each turn**, Glen's Stop hook records what happened. In Claude Code that includes tool calls, tool results and thinking blocks; in Codex, the prompt and final reply. 2. **Before the next prompt reaches the model**, the UserPromptSubmit hook sends the prompt with repo and branch, and Glen injects the memories that match. 3. **When the agent needs more**, it can run `glen search` for a written answer with a citation behind each claim, or `glen code-search` to follow git blame back to the conversation that wrote a line. > **Injected or on demand:** Claude Code, Codex and Pi get recall before the model reads the prompt. Cursor and Grok Build hooks can't add context, so recall there happens when the agent runs `glen search`. > **Stop rediscovering what a past session already knew** Glen records each turn as it ends and recalls it when the next prompt needs it. Start free with 15,000 memories. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## Why long-term memory has to be selective Long-term memory competes with the task for room in the short-term window. Recall that pastes in everything crowds out the code the agent should be reading. Glen recalls by relevance to the prompt, so a month of a team's sessions costs the agent only the few memories that bear on the change at hand. For more on budgeting the window itself, see [context window memory](https://contextmemory.app). Does the extra recall pay for itself? In Glen's own replay of 100 merged PRs, agents with memory used 29% fewer tokens and finished 21% faster at equal or better quality. That replay used per-prompt injection, so agents that only search on demand may see different numbers. [The full method](https://tryglen.com/blog/replaying-100-prs) is published. ## Frequently asked questions ### What is short-term memory in AI? The context window: everything the model can see during the current session. It is cleared when the session ends and trimmed as it fills. ### Is the context window the same as memory? It is working memory for one session. Anything you want an agent to know next week has to be stored outside the model and loaded back into the window later. ### Does a bigger context window remove the need for long-term memory? No. A bigger window holds more of today's session, but it still empties when the session ends, and it never contains a teammate's sessions. --- # Episodic, semantic and procedural memory for AI agents URL: https://longtermmemoryai.dev/types-of-memory Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > Agent-memory writing borrows three long-term memory types from cognitive science: episodic (what happened in a particular session), semantic (facts and decisions that hold regardless of when you learned them) and procedural (how to do a task). In a coding team's memory these map to recorded agent sessions, the decisions recalled from them, and reusable skills. Glen keeps all three for an organization. ## Three kinds of long-term memory Cognitive science splits human long-term memory into remembering events, knowing facts, and knowing how. The same split is a practical way to sort what an AI agent should keep, because each kind is captured, stored and used differently. *Memory types mapped onto a team of coding agents* | Type | In people | In a coding agent | Where Glen keeps it | | --- | --- | --- | --- | | Episodic | Remembering last Tuesday's outage call | The transcript of the session that fixed the outage | Transcript library, searchable and shareable | | Semantic | Knowing the payments service owns refunds | "Refunds go through the payments service" | Memories recalled into context by relevance | | Procedural | Knowing how to ride a bike | The steps to cut a release or add a migration | Skills library | Working memory, the fourth term you'll see, is the context window. It is covered on the [short-term vs long-term page](https://longtermmemoryai.dev/short-term-vs-long-term). ## Episodic memory: the sessions themselves An episode is one conversation with a beginning and an end: the prompt, what the agent tried, what failed, what shipped. Glen's plugins record each turn through the agent's hooks, and the transcript library keeps those sessions searchable and shareable inside the organization. Episodes matter most when you need the story behind code. `glen code-search ""` follows git blame from a range of lines to the agent conversations that wrote them, which is possible because the Claude Code plugin links each `git commit` to its session. ## Semantic memory: facts and decisions Most of the time an agent doesn't need the whole episode, just the conclusion: which queue the webhooks use, which library the team dropped and why. These are the memories Glen recalls into the context window when a prompt touches the same ground, and the ones `glen search` cites when it writes an answer. Semantic memory is also where staleness bites, because a fact outlives the episode that taught it. When a decision is reversed, Glen aims to recall the newer one. If the old one keeps coming back, `glen forget` takes it out of recall and `glen restore` undoes that. Tools that store semantic memory as a graph instead are covered in [AI agent memory tools compared](https://aiagentmemory.app/compared). ## Procedural memory: skills Procedural memory is how-to knowledge: the sequence of steps a task needs. For agents this has two homes. Steps that must run every time go in `AGENTS.md` or `CLAUDE.md`, where the agent reads them without searching. Longer workflows that apply only sometimes fit better as skills. Glen's skills library takes the skills you upload, distils new ones from the work your team's agents do, and surfaces the right one on its own when a task calls for it. MCP clients reach the same library through `glen_skill_search` and `glen_skill_use`. > **Keep all three kinds of memory for your team** Sessions, decisions and skills, recorded from the agents you already use. Free covers 15,000 memories and up to 3 people. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## Frequently asked questions ### What is episodic memory in AI agents? A record of specific past sessions: what was asked, what the agent did and how it ended. In Glen that is the recorded transcript of each agent conversation. ### What is the difference between semantic and episodic memory in AI? Episodic memory is the event (the session where the team chose a queue); semantic memory is the fact that remains (webhooks go through the queue). Agents usually need the fact and reach for the episode when they need the reasoning. ### What is procedural memory for an AI agent? Knowledge of how to do a task, such as releasing or adding a migration. Agents keep it in instruction files for steps that always apply and in skills for workflows that apply only sometimes. ### Is Glen a knowledge graph? No. Glen records sessions and connected sources into an organization memory and recalls by relevance. It is not a graph or a database you query directly. --- # Give your agents long-term memory, starting with the history you already have URL: https://longtermmemoryai.dev/setup Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > Run npx @tryglen/cli@latest install, choose which coding agents get the plugin, and sign in. Then run glen import to backfill your old local sessions, so recall starts with your last 30 days instead of an empty store. From then on every turn is recorded and recalled automatically. Long-term memory that starts empty takes weeks to become useful. The quickest route is to install, then import the sessions already sitting on your disk. You need Node.js. 1. **Install the CLI and plugins** The installer finds the coding agents on your machine and asks which ones should get the Glen plugin. ```bash npx @tryglen/cli@latest install ``` 2. **Sign in to your organization** The installer offers to sign you in. Your memory belongs to the organization you pick, so choose the one your team will share. 3. **Import your past sessions** Backfill old local agent sessions into memory. Glen's own advice is to import your last 30 days on day one. Skip it and recall has little to draw on until new sessions pile up. ```bash glen import ``` 4. **Ask a question only your history can answer** Pick something you worked out weeks ago. The answer comes back with a citation for every claim, in about 10 seconds. A model writes it, so open the sources before you rely on it. ```bash glen search "why did we stop retrying failed uploads inline" ``` 5. **Start a new agent session and work** Hooks load at session start. From here every turn is recorded, and agents with per-prompt recall get matching memories before the model reads each prompt. ## How recall reaches each agent *Recall style per coding agent with Glen installed* | Agent | How recall arrives | Docs | | --- | --- | --- | | Claude Code | Injected before the model reads each prompt | [tryglen.com/docs/claude-code](https://tryglen.com/docs/claude-code) | | Codex | Injected each prompt through UserPromptSubmit's additionalContext | [tryglen.com/docs/codex](https://tryglen.com/docs/codex) | | Pi | At the start of every turn | [tryglen.com/docs/pi](https://tryglen.com/docs/pi) | | Cursor | On demand, when the agent runs `glen search` | [tryglen.com/docs/cursor](https://tryglen.com/docs/cursor) | | Grok Build | On demand, when the agent runs `glen search` | [tryglen.com/docs/grok](https://tryglen.com/docs/grok) | ## Keeping long-term memory accurate - Promote a decision that should always hold into `AGENTS.md` or `CLAUDE.md`, so it no longer depends on recall. - When recall brings back something the team has since reversed, run `glen forget` on it. It is reversible with restore. - For work that should not become team memory, `glen incognito` keeps recall on and records nothing. `glen off` stops both; `glen silent` records but surfaces nothing. > **Import your history and start recalling today** One install command, then glen import. Free covers 15,000 memories and up to 3 people, no credit card. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com Bringing teammates in next? [Setting up memory for a team's agents](https://memoryforaiagents.com/setup) starts from invites. Glen is hosted only, with no self-hosted build, and does not train models on your content. See the [privacy policy](https://tryglen.com/privacy) and [sub-processors](https://tryglen.com/sub-processors). ## Frequently asked questions ### Can I import old AI agent conversations into Glen? Yes. glen import backfills old local coding-agent sessions into your organization's memory. Importing your last 30 days on day one is the recommended start. ### How much long-term memory does the free plan hold? Free holds 15,000 memories for up to 3 people. Personal goes to 250,000 memories and adds integrations, and Team has no limits. ### Can I keep some sessions out of long-term memory? Yes. glen incognito stops recording to team memory while recall keeps working, and the mode applies account-wide.