Introduction
Memory defines intelligence in AI systems. Without it, even the best reasoning models repeat themselves, lose context, and make brittle decisions.
In this article, we will explore how to build memory-aware ReAct agents using LangChain, LangGraph, and LangMem. You will learn how to retain history, plan across multiple steps, and integrate persistent memory into real-world deployments.
Why Production Agents Need Memory
LLMs forget between calls. Prompt engineering only stretches the limits of token windows, but cannot guarantee consistency or continuity.
Memory is essential for:
- Multi-step workflows
- Dynamic tool chains
- Enterprise chatbots with compliance history
- Agents that justify or reflect on past actions
LangChain offers buffer and vector-based memory options. LangGraph enables memory-aware execution. LangMem introduces persistent memory across sessions, agents, and namespaces.
Choosing the Right ReAct Agent API
LangChain’s create_react_agent() is effective for quick prototyping. However, in production, it is recommended to use LangGraph’s native ReAct agent, which supports deterministic reasoning and memory integration.
Clarification:
- LangChain (legacy):
create_react_agent(llm, tools, memory) - LangGraph (preferred): ReAct implemented using graph state and memory routing
Reference:
LangGraph ReAct agent documentation:
https://langchain-ai.github.io/langgraph/agent_patterns/react/
Memory Tools in LangChain
LangChain supports multiple memory modules:
| Memory Type | Description | Persistent |
|---|---|---|
| ConversationBuffer | Holds recent user/agent turns | No |
| VectorStoreMemory | Stores embedded documents for semantic recall | Yes |
| ReadOnlyMemory | Injects constant context | Yes |
| Redis / ChromaDB | Stores persistent chat or data | Yes |
For long-running agents, combine LangGraph orchestration with Redis or Chroma for fault-tolerant memory systems.
Code Example: Planning with LangChain ReAct Agent
from langchain.agents import create_react_agent
from langchain.llms import OpenAI
from langchain.memory import ConversationBufferMemory
from langchain.tools import Tool
def search_tool(query):
return f"Search results for: {query}"
llm = OpenAI(model="gpt-4")
memory = ConversationBufferMemory(return_messages=True)
agent = create_react_agent(
llm=llm,
tools=[Tool(name="search", func=search_tool, description="Search the web")],
memory=memory
)
agent.run("Summarize the leadership style of Satya Nadella.")
This pattern demonstrates a reactive agent with a short-term memory buffer. In production, substitute LangGraph for better control of agent state and planning.
LangGraph for Memory-Aware Workflows
LangGraph models agents as graph nodes that can pass memory, results, and control flows.
Use version v0.0.20 or newer to ensure support for:
- Memory propagation between steps
- Cross-agent planning
- Stateful graph transitions
from langgraph.graph import StateGraph
graph = StateGraph()
graph.add_node("plan", plan_function)
graph.add_node("write", write_function)
graph.add_edge("plan", "write")
compiled = graph.compile()
compiled.invoke({"topic": "LLM agent memory architecture"})
Full memory support documentation:
https://langchain-ai.github.io/langgraph/concepts/memory/
Persistent Multi-Agent Memory with LangMem
LangMem extends LangChain with advanced memory APIs, offering:
- Indexed long-term memory
- Namespace partitioning for multi-user agents
- Write/search/edit/delete memory chunks
- Pluggable storage backends
Supported Storage Engines
| Store | Description |
|---|---|
| InMemoryStore | Non-persistent; used in dev/test |
| AsyncPostgresStore | PostgreSQL-based persistent backend |
| ChromaStore | Embedding-compatible vector store |
LangMem Use Case Example
from langmem import create_manage_memory_tool
tool = create_manage_memory_tool(
memory_namespace="client_acme_corp",
embedding_model="openai"
)
This allows different agents (or teams) to write and read memory scoped by client, user, or project.
Repository: https://github.com/langchain-ai/langmem
Memory-Aware ReAct Agent

Comparison Table: Legacy vs Production Agent Frameworks
| Capability | LangChain ReAct Agent | LangGraph + LangMem |
|---|---|---|
| Tool chaining | Yes | Yes |
| Memory support | Buffer only | Persistent, namespaced |
| Multi-agent orchestration | Manual | Built-in via graphs |
| Session continuity | Limited | Durable |
| User isolation | No | Yes (via namespaces) |
Preview: CrewAI for Agent Collaboration
CrewAI provides a high-level framework for coordinating role-based agents. It supports:
- Agent roles (e.g., researcher, writer, planner)
- Task pipelines with dependencies
- Goal-oriented crews with memory and state
In the next article, we will show how to combine LangGraph’s memory system with CrewAI’s structured collaboration, enabling large-scale autonomous workflows.
CrewAI Documentation:
https://docs.crewai.com
Critical Questions Before Deploying
- Do your agents share memory, or operate in isolation?
- Are there compliance requirements for memory segregation by tenant or user?
- Will human approvals be injected into the workflow?
- Are you building workflows that span multiple tool invocations or API calls?
- Do you need memory to persist between user sessions or system restarts?
References
- LangGraph ReAct Agent: https://langchain-ai.github.io/langgraph/agent_patterns/react/
- LangMem Project: https://github.com/langchain-ai/langmem
- LangChain Memory Interfaces: https://python.langchain.com/docs/modules/memory/
- Redis History Backend: https://python.langchain.com/docs/modules/memory/chat_message_histories/redis/
- CrewAI Preview: https://docs.crewai.com
Final Thoughts
Memory transforms LLM-based agents into true decision-making systems. By adopting LangGraph for orchestration, LangMem for persistence, and CrewAI for coordination, you can move beyond chatbots into multi-agent cognitive frameworks.
Introduction Are you building AI agents that interact with APIs, run functions, or query real-world services? Then you’re already entering the world...