A LangChain chatbot does not remember earlier API calls automatically. In the current Python architecture, add a LangGraph checkpointer and reuse a stable thread_id on every request. That provides short-term memory for one conversation. Use a database-backed checkpointer for durable history, and a separate LangGraph store for user facts that must survive across conversations.
What “memory” means in LangChain
An LLM only sees the messages and other state your application sends for the current invocation. Your application must retrieve earlier state and include the relevant parts in the next model call.
Conversation history
This is the ordered sequence of messages in one conversation:
User: My name is Maya.
Assistant: Nice to meet you, Maya.
User: What is my name?
Short-term memory
Short-term memory is thread-scoped state used to continue a conversation. It can contain messages, tool results, uploaded files, retrieved documents, and other graph state. LangGraph persists that state as checkpoints. See LangChain’s memory concepts.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Long-term memory
Long-term memory is information shared across separate threads, such as a user’s preferred language, dietary restriction, or an account fact. LangGraph stores these memories as JSON documents organized by namespace and key. A checkpointer preserves one thread; it is not automatically a user-profile database. See the long-term memory guide.
What you will build
The example uses Python, the current create_agent API, one chat model, no tools, and an in-memory checkpointer. The same thread recalls facts; a different thread does not.
Prerequisites and installation
Current LangChain Python documentation requires Python 3.10 or newer. Install the core packages and a provider integration in a virtual environment. Provider setup details are in the installation guide and quickstart.
python -m venv .venv
source .venv/bin/activate
# Windows PowerShell: .venvScriptsactivate
pip install -U langchain langgraph langchain-openai
export OPENAI_API_KEY="your-api-key"
# Windows PowerShell:
# $env:OPENAI_API_KEY="your-api-key"
openai:gpt-5.4 is the model identifier shown in current documentation, not a guarantee that it is available for every account or region. Replace it with a model supported by your provider. LangChain also documents integrations for Anthropic, Google, Azure, AWS Bedrock, OpenRouter, Fireworks, Ollama, and others. For Anthropic, install langchain-anthropic and set ANTHROPIC_API_KEY; see the Anthropic integration page.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesBuild the basic chatbot with thread memory
Run this complete example:
from langchain.agents import create_agent
from langgraph.checkpoint.memory import InMemorySaver
checkpointer = InMemorySaver()
agent = create_agent(
model="openai:gpt-5.4",
tools=[],
system_prompt=(
"You are a helpful chatbot. "
"Use the conversation history to answer follow-up questions."
),
checkpointer=checkpointer,
)
thread_a = {"configurable": {"thread_id": "user-42-chat-1"}}
thread_b = {"configurable": {"thread_id": "user-42-chat-2"}}
agent.invoke(
{
"messages": [
{"role": "user", "content": "I prefer concise answers and my name is Maya."}
]
},
thread_a,
)
answer = agent.invoke(
{
"messages": [
{"role": "user", "content": "What answer style do I prefer, and what is my name?"}
]
},
thread_a,
)
print(answer["messages"][-1].content)
new_conversation = agent.invoke(
{"messages": [{"role": "user", "content": "What is my name?"}]},
thread_b,
)
print(new_conversation["messages"][-1].content)
The second call on thread_a can answer “Maya” and “concise.” The call on thread_b has no history from thread_a. This is thread memory, not a cross-session user-memory system.
How the thread ID contract works
checkpointer=... enables persistence, while configurable.thread_id selects which checkpointed conversation to load. Reuse the same logical ID for follow-up requests; generating a new random ID on every request creates a new conversation. LangChain’s reference requires a thread ID when invoking a graph with a checkpointer; see the checkpointer reference.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
A thread normally represents one conversation, not an entire user. A practical identifier is:
thread_id = application_user_id + ":" + conversation_id
Store the conversation ID in your application database or authenticated session. On every request, verify that the authenticated user owns it. Never let possession of an arbitrary client-supplied ID expose another customer’s history.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Why current LangChain tutorials use create_agent
Many search results show ConversationBufferMemory, ConversationChain, or LLMChain. Those examples may target older releases. In the current agent architecture, conversational state is graph state persisted by a checkpointer. Use version-specific legacy documentation if you maintain an older chain; do not mix old memory classes into a current-agent tutorial. The current quickstart uses from langchain.agents import create_agent.
Make conversation memory durable
What InMemorySaver is—and is not
InMemorySaver is appropriate for tutorials, local experiments, unit tests, and disposable sessions. Its data disappears when the process exits, a container is replaced, or a request reaches a different worker that has its own memory. It is not durable production storage.
PostgreSQL checkpointer
Install the documented PostgreSQL saver:
pip install langgraph-checkpoint-postgres
from langchain.agents import create_agent
from langgraph.checkpoint.postgres import PostgresSaver
DB_URI = (
"postgresql://postgres:postgres@localhost:5432/postgres"
"?sslmode=disable"
)
with PostgresSaver.from_conn_string(DB_URI) as checkpointer:
checkpointer.setup()
agent = create_agent(
model="openai:gpt-5.4",
tools=[],
checkpointer=checkpointer,
)
config = {"configurable": {"thread_id": "production-conversation-1"}}
result = agent.invoke(
{"messages": [{"role": "user", "content": "Remember that I prefer email."}]},
config,
)
print(result["messages"][-1].content)
setup() creates the required schema in this documented pattern. Confirm migrations and APIs against the exact saver version you install. In production, keep the connection string in a secret manager, enable TLS, use a least-privileged database role, configure pooling, and back up the database. LangChain also documents SQLite, PostgreSQL, and Azure Cosmos DB persistence options; choose according to durability, concurrency, and operations. See short-term memory documentation.
Add memory that survives new conversations
Starting thread-2 does not automatically expose thread-1 messages. Add a LangGraph store for user-scoped facts:
Recommended Free Tools
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
namespace = ("users", authenticated_user_id)
A record could be:
{
"name": "Maya",
"response_style": "concise",
"language": "English"
}
Retrieve authorized records and deliberately provide them to the agent as data. Store only facts that are explicitly requested, stable, safe to retain, correctly attributed, and easy to inspect or delete.
Hot-path writes
Save a confirmed memory during the request when it must be available immediately. This is deterministic but adds latency and requires extraction and validation.
Background writes
Queue extraction after responding to keep chat latency lower. The next request may not see the memory, so use a reliable worker, retries, deduplication, and idempotency.
Control long conversation history
Appending every message forever increases latency and input-token cost, can exceed the model context window, and leaves stale instructions competing with current requests. LangChain’s memory guidance covers context limits and memory management.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Trim
Keep the newest messages while preserving complete assistant/tool-call boundaries. This suits casual or task-focused bots but can drop older facts.
Summarize
Replace old turns with a compact summary containing goals, decisions, constraints, important facts, unresolved questions, and durable tool results. A summary is model-generated state and may omit or distort information.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Hybrid memory
Use recent raw messages, a compact summary, explicit long-term facts, and retrieved application records. This usually gives better relevance than sending the full transcript indefinitely. The LangGraph history-management guide covers trimming, deletion, summarization, state inspection, and checkpoint deletion.
Secure and test chatbot memory
- Bind every thread to an authenticated user and authorize every read and write.
- Use user-scoped store namespaces such as
("users", user_id). - Define retention, deletion, correction, and export procedures for personal data.
- Record provenance and timestamps for durable facts; distinguish explicit memories from inferences.
- Treat stored messages, summaries, memories, and retrieved documents as untrusted data, not authorization instructions.
- Keep system and developer instructions separate from user history and revalidate permissions on every request.
- Test that the same thread recalls context, a different thread does not, one user cannot read another’s thread, restarts behave differently for in-memory and durable savers, and trimming preserves valid tool-call message boundaries.
Common failures and recovery
The bot forgets everything
Check for a new ID on every request, a missing invocation config, a process restart, worker-local memory, an uninitialized database saver, or a frontend that failed to persist the conversation ID. Log the authenticated user and thread ID, inspect checkpoint existence, then move to shared durable storage.
Users see one another’s memory
Look for a global hard-coded ID, missing ownership checks, unscoped long-term namespaces, or shared test and production data. Generate unique conversation IDs, bind them to users, authorize every operation, and add cross-tenant tests.
Requests fail as history grows
Trim or summarize old turns, avoid repeatedly storing retrieved documents, refresh summaries, define checkpoint retention, and monitor token budgets before invocation.
The chatbot remembers a wrong fact
Require explicit confirmation for durable memories, retain provenance and timestamps, let users correct or delete records, and prefer current application records over generated recollections.
Old instructions override the current request
Never use remembered text as an authorization decision. Revalidate permissions and apply prompt-injection defenses to stored memories and retrieved documents.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Tool calls break after trimming
Preserve valid message ordering and complete assistant/tool-call pairs. Keep important tool results in structured state and test provider-specific message formats.
Production architecture and choices
Frontend
│ authenticated user ID + conversation ID
API service
├── LangChain agent
├── checkpointer ── PostgreSQL (or another durable saver)
├── long-term store ── user memories
└── optional tracing/evaluation
| Requirement | Recommended approach | Trade-off |
|---|---|---|
| Quick demo or unit test | InMemorySaver |
Data disappears on restart |
| Durable conversations | Database-backed checkpointer | Database operations and cost |
| Preferences across chats | Long-term store | More modeling and privacy responsibility |
| Very long chats | Trim, summarize, or use a hybrid | Possible context loss or distortion |
| Tracing and evaluation | Optional LangSmith | Hosted-service and usage considerations |
Provider integrations standardize interfaces but not capabilities. Tool calling, structured output, streaming, multimodal input, limits, latency, and pricing vary by model and provider; consult the provider integration overview. LangSmith is optional; its current pricing is listed at langchain.com/pricing.
When not to use LangChain memory
- Use a stateless completion for a genuinely single-turn request.
- Use your existing application database directly when it already owns chat messages and you do not need agent graph state.
- Use a conventional workflow record when no agent or tool state is involved.
- Use process-local memory only when losing state on restart is acceptable.
Frequently Asked Questions
Does a checkpointer remember a user across every conversation?
No. It preserves state for one thread. Cross-conversation preferences require a separate LangGraph store and explicit retrieval.
Why does a new thread ID appear to erase memory?
A new thread ID selects a different conversation checkpoint. Reuse the authorized conversation’s stable ID for follow-up requests.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Is InMemorySaver suitable for production?
Only for disposable sessions, tests, or prototypes. Use a shared durable checkpointer when history must survive restarts or multiple workers.
The Bottom Line
For a current LangChain chatbot, configure create_agent with a checkpointer and pass the same authorized thread_id on follow-up requests. Upgrade to a durable saver for production, and add a user-scoped store only when you need memory across separate conversations.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

