memory

A guide to giving agents memory across conversations. Short-term memory keeps the current session's messages, while long-term memory stores user or application information for later sessions.

In plain words
What is it for?
Use it to support multi-turn conversations, save agent state by session, and keep information available across separate sessions.
Why use it?
Without memory, an agent may lose the earlier parts of a conversation or information saved from previous sessions. The guide explains the identifiers and storage setup needed to retain that state.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/langchain-ai/langgraphjs/memory
Clone the repo
git clone --depth 1 https://github.com/langchain-ai/langgraphjs
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,543 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02543
Opus 5 $0.00000 $0.01272
Sonnet 5 $0.00000 $0.00509
Haiku 4.5 $0.00000 $0.00254

Measured yesterday against content hash 8d4f1687fe18, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/docs/agents/memory.md · 241 lines

How it starts

The opening of the file, as written. The whole thing — 241 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory

LangGraph supports two types of memory essential for building conversational agents:

  • Short-term memory: Tracks the ongoing conversation by maintaining message history within a session.
  • Long-term memory: Stores user-specific or application-level data across sessions.

This guide demonstrates how to use both memory types with agents in LangGraph. For a deeper understanding of memory concepts, refer to the LangGraph memory documentation.

!!! note "Terminology"

In LangGraph:

- *Short-term memory* is also referred to as **thread-level memory**.
- *Long-term memory* is also called **cross-thread memory**.

A [thread](../concepts/persistence.md#threads) represents a sequence of related runs
grouped by the same `thread_id`.

Short-term memory

Short-term memory enables agents to track multi-turn conversations. To use it, you must:

  1. Provide a checkpointer when creating the agent. The checkpointer enables persistence of the agent's state.
  2. Supply a thread_id in the config when running the agent. The thread_id is a unique identifier for the conversation session.
// highlight-next-line
import { MemorySaver } from "@langchain/langgraph-checkpoint";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { initChatModel } from "langchain/chat_models/universal";
import { tool } from "@langchain/core/tools";
import { z } from "zod";

// highlight-next-line
const checkpointer = new MemorySaver();  // (1)!

const getWeather = tool(
  async (input: { city: string }) => {
    return `It's always sunny in ${input.city}!`;
  },
  {
    name: "getWeather",
    schema: z.object({
      city: z.string().describe("The city to get the weather for"),
    }),
    description: "Get weather for a given city.",
  }
);

const llm = await initChatModel("anthropic:claude-3-7-sonnet-latest");
const agent = createReactAgent({
  llm,
  tools: [getWeather],
  // highlight-next-line
  checkpointer  // (2)!
});

// Run the agent
// highlight-next-line
const config = { configurable: { thread_id: "1" } };  // (3)!
const sfResponse = await agent.invoke(
  { messages: [ { role: "user", content: "what is the weather in sf" } ] },
  config  // (4)!
);
const nyResponse = await agent.invoke(
  { messages: [ { role: "user", content: "what about new york?" } ] },
  config
);

Read the full file on GitHub · 241 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 241 lines · 0 tokens per session scan A 8d4f1687fe18

Subscribe to this mod's changes

memory is an agent published in the GitHub repository langchain-ai/langgraphjs (3,242 stars, last pushed 5d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,543 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

affaan-m-agentshield

Explain why this repository is useful for advanced web development, 3D frontend, animations, UI systems, or creative development.

SAIRAMANALADI/vybe-intelligence-vault · 0 tokens

akihirookuda95-openai-agents-sdk-tutorial

Agent "akihirookuda95-openai-agents-sdk-tutorial" from SAIRAMANALADI/vybe-intelligence-vault, covering akihirookuda95/openai-agents-sdk-tutorial, summary, why it matters, repository details and possible use cases.

SAIRAMANALADI/vybe-intelligence-vault · 0 tokens

alexpeclub-ai-coding-starter-kit

Explain why this repository is useful for advanced web development, 3D frontend, animations, UI systems, or creative development.

SAIRAMANALADI/vybe-intelligence-vault · 0 tokens

overview

The Agent Starter Pack follows a "bring your own agent" approach. It provides several production-ready agent templates designed to accelerate your development while offering the flexibility to use your preferred agent framework or pattern.

GoogleCloudPlatform/agent-starter-pack · 0 tokens

iteration

The iteration agent of /auto. Runs the /auto-iteration-loop skill — an autonomous review loop that consumes /auto-verify's four-state output (PASS / FAIL / INCONCLUSIVE / ZEROELIGIBLEVARIANTS) plus the orthogonal deferred bucket and routes each claim to the right back-edge (① variant-only fix / ② baseline-script fix /…

zjunlp/Mechanist · 143 tokens

huyen-agents

Updated 2025: This is a summary of Chip Huyen's blog and book chapter on agents, with some added context to provide a comprehensive overview of their design, capabilities, and practical applications.

alirezadir/Agentic-AI-Systems · 0 tokens