---
source: https://iinventedlight.com/library/notes/ao-memory-short-vs-long-term.md
title: "Agent memory: thread-scoped vs cross-session, and file-based memory"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 or MIT (repo docs; LICENSE file verified in each GitHub repo); prose restates cited source lines in own words"
license_family: agentops-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: LangChain docs (GitHub), Memory overview, MIT (langchain-ai/docs LICENSE); Google Gemini CLI docs (GitHub), Memory files, Apache-2.0 (google-gemini/gemini-cli LICENSE)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No tool or code was run for this note; only the fetched repository documentation was read."
category: agent-operations
topic_area: "agent operations: long-running agent memory"
tags: [memory, langgraph, gemini-cli, agents]
client: Librarian
sources:
  - id: S1
    title: "Memory overview"
    publisher: LangChain docs (GitHub)
    url: https://github.com/langchain-ai/docs/blob/main/src/oss/concepts/memory.mdx
    accessed: 2026-11-09
    license: "MIT (langchain-ai/docs LICENSE)"
  - id: S2
    title: "Memory files"
    publisher: Google Gemini CLI docs (GitHub)
    url: https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/memory.md
    accessed: 2026-11-09
    license: "Apache-2.0 (google-gemini/gemini-cli LICENSE)"
---
# Agent memory: thread-scoped vs cross-session, and file-based memory

**Answer:** Split agent memory by recall scope. Short-term (thread-scoped) memory is the ongoing conversation; long-term memory stores user-specific or application-level data across sessions and threads.

## Short-term memory

LangGraph manages short-term memory as part of the agent's state, persisted by a checkpointer so the thread can be resumed. A full history may not fit inside the context window, and most LLMs still perform poorly over long contexts, getting distracted by stale or off-topic content.

## Long-term memory

Long-term memory is shared across conversational threads and scoped to a custom namespace; LangGraph stores save and recall it. Memory types borrow from psychology: facts (semantic memory), experiences (episodic memory), and rules (procedural memory).

## File-based memory (Gemini CLI)

Gemini CLI persists durable facts and user preferences by editing Markdown memory files:
- shared project instructions in repository `GEMINI.md` files;
- private project notes in a per-project private memory folder;
- cross-project personal preferences in the global `~/.gemini/GEMINI.md`.

Stored facts are included in context for all future sessions; keep them concise and avoid duplicating the same fact across tiers.

## Artifacts

- [Topic packet: ao-memory](https://iinventedlight.com/library/packets/ao-memory.json)

## See also

- [ao-memory-mechanisms-survey](https://iinventedlight.com/library/notes/ao-memory-mechanisms-survey/)
- [ao-memory-long-term-benchmarks](https://iinventedlight.com/library/notes/ao-memory-long-term-benchmarks/)
- [ao-rules-gemini-md-hierarchy](https://iinventedlight.com/library/notes/ao-rules-gemini-md-hierarchy/)

## Claims

- id: C1
  claim: Short-term memory is thread-scoped.
  source: S1
  evidence: "Short-term memory, or thread-scoped memory, tracks the ongoing conversation"

- id: C2
  claim: Long-term memory spans sessions.
  source: S1
  evidence: "stores user-specific or application-level data across sessions"

- id: C3
  claim: Long contexts distract LLMs with stale content.
  source: S1
  evidence: "most LLMs still perform poorly over long contexts."

- id: C4
  claim: Gemini CLI memory lives in Markdown files.
  source: S2
  evidence: "persists durable facts, user preferences, and project details by"

- id: C5
  claim: Avoid duplicating facts across memory tiers.
  source: S2
  evidence: "avoids duplicating the same fact across multiple memory tiers."

## Sources

- [S1] Memory overview. LangChain docs (GitHub). https://github.com/langchain-ai/docs/blob/main/src/oss/concepts/memory.mdx . License: MIT (langchain-ai/docs LICENSE). Accessed 2026-11-09.

- [S2] Memory files. Google Gemini CLI docs (GitHub). https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/memory.md . License: Apache-2.0 (google-gemini/gemini-cli LICENSE). Accessed 2026-11-09.


License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: GitHub repository docs under Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0) or MIT License (https://opensource.org/licenses/MIT), as listed per source; copyright notices remain with the original authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
