[PR #1244] [MERGED] fix(docs): add checkpointer=InMemorySaver() to trim_messages example for persistent memory #1401

Closed
opened 2026-02-17 17:22:18 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/1244
Author: @leonyangdev
Created: 11/2/2025
Status: Merged
Merged: 11/17/2025
Merged by: @lnhsingh

Base: mainHead: main


📝 Commits (2)

  • 8a1afdf fix(docs): add checkpointer=InMemorySaver() to trim_messages example for persistent memory
  • 3b35397 Merge branch 'main' into main

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 src/oss/langchain/short-term-memory.mdx (+2 -1)

📄 Description

Overview

This PR updates the trim_messages example in the documentation to include
checkpointer=InMemorySaver().

Without the checkpointer, each agent.invoke() call starts a new conversation thread, causing the agent to forget previous context (e.g., the user’s name).
This change ensures persistent memory across invocations and aligns the example’s behavior with the printed output shown in the docs.


Type of change

Type: Update existing documentation


Related issues/PRs

None directly.
This PR addresses confusion reported by users when reproducing the trim_messages example —
the code output did not match the example’s described behavior without adding a checkpointer.


Checklist

  • I have read the contributing guidelines
  • I have tested the code example locally
  • The example now behaves as described (Your name is Bob is remembered)
  • All code examples work correctly
  • Root-relative paths are used for internal links

Additional notes

This change makes the example self-contained and beginner-friendly.
It clarifies that persistent memory requires an explicit checkpointer when using create_agent() with multi-turn interactions.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/1244 **Author:** [@leonyangdev](https://github.com/leonyangdev) **Created:** 11/2/2025 **Status:** ✅ Merged **Merged:** 11/17/2025 **Merged by:** [@lnhsingh](https://github.com/lnhsingh) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`8a1afdf`](https://github.com/langchain-ai/docs/commit/8a1afdfc75d0186b4f80da07ee802c56ee101774) fix(docs): add checkpointer=InMemorySaver() to trim_messages example for persistent memory - [`3b35397`](https://github.com/langchain-ai/docs/commit/3b35397816499adc55a0fa963867d2055620fcab) Merge branch 'main' into main ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/langchain/short-term-memory.mdx` (+2 -1) </details> ### 📄 Description ## Overview This PR updates the `trim_messages` example in the documentation to include `checkpointer=InMemorySaver()`. Without the checkpointer, each `agent.invoke()` call starts a new conversation thread, causing the agent to forget previous context (e.g., the user’s name). This change ensures persistent memory across invocations and aligns the example’s behavior with the printed output shown in the docs. --- ## Type of change **Type:** Update existing documentation --- ## Related issues/PRs None directly. This PR addresses confusion reported by users when reproducing the `trim_messages` example — the code output did not match the example’s described behavior without adding a `checkpointer`. --- ## Checklist * [x] I have read the contributing guidelines * [x] I have tested the code example locally * [x] The example now behaves as described (`Your name is Bob` is remembered) * [x] All code examples work correctly * [x] Root-relative paths are used for internal links --- ## Additional notes This change makes the example self-contained and beginner-friendly. It clarifies that persistent memory requires an explicit checkpointer when using `create_agent()` with multi-turn interactions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:22:18 -05:00
yindo closed this issue 2026-02-17 17:22:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#1401