Skip to content

Conversation

@hefeng6500
Copy link

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.

@hefeng6500 hefeng6500 requested a review from lnhsingh as a code owner November 3, 2025 03:42
@github-actions github-actions bot added langchain For docs changes to LangChain oss labels Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

langchain For docs changes to LangChain oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant