Memory tools
Memory tools are two LangChain tools from LangMem, manage_memory and search_memory, that let an agent save, update, delete and search memories in the store itself, during the conversation.
Last updated: 30 Sep, 2026 · LangMem 0.0.30
A store manager decides after a chat what to remember. Memory tools move that decision into the conversation: the agent calls manage_memory when the customer says something worth keeping, and search_memory before answering. This lesson calls the tools directly, the way an agent would, to see what each one takes and returns.
Syntax:
save = create_manage_memory_tool(namespace=("memories", "{user_id}"), store=store)
find = create_search_memory_tool(namespace=("memories", "{user_id}"), store=store)The manage_memory tool
A tool is what a model sees: a name, a description and arguments. manage_memory takes content, an action of create, update or delete, and an id for the last two.
save = create_manage_memory_tool(namespace=("memories", "{user_id}"), store=store)
print(save.name, list(save.args))Calling a tool with a config
The namespace template is filled from the config, as with the store manager.
asha = {"configurable": {"user_id": "asha"}}
save.invoke({"content": "Order A-1001 arrived broken", "action": "create"}, config=asha)Saving and searching with the tools
import json
from langgraph.store.memory import InMemoryStore
from langmem import create_manage_memory_tool, create_search_memory_tool
store = InMemoryStore(index={"dims": 3072, "embed": "google_genai:gemini-embedding-2"})
save = create_manage_memory_tool(namespace=("memories", "{user_id}"), store=store)
find = create_search_memory_tool(namespace=("memories", "{user_id}"), store=store)
print(save.name, list(save.args), "|", find.name, list(find.args))
asha = {"configurable": {"user_id": "asha"}}
print(save.invoke({"content": "Order A-1001 arrived broken", "action": "create"}, config=asha)[:15])
print(save.invoke({"content": "Wants us to email her", "action": "create"}, config=asha)[:15])
results = json.loads(find.invoke({"query": "damaged parcel"}, config=asha))
for row in results:
print(round(row["score"], 3), row["value"]["content"])manage_memory ['content', 'action', 'id'] | search_memory ['query', 'limit', 'offset', 'filter'] created memory created memory 0.652 Order A-1001 arrived broken 0.517 Wants us to email her
What the tools returned
- The tools' arguments are what an agent fills in:
content,actionandidformanage_memory;query,limit,offsetandfilterforsearch_memory. - create returns text, "created memory" followed by the new id; the example prints only the first 15 characters, so the id is cut off. That text is what the agent reads back as the tool result.
- search returns JSON, best match first. "damaged parcel" found "Order A-1001 arrived broken" at 0.652, above the email preference at 0.517.
Memory tools vs a store manager
| Memory tools | Store manager | |
|---|---|---|
| Who decides what to save | The agent, during the chat | A separate model call after the chat |
| Effect on the reply | Extra tool calls before the answer | None, if run in the background |
| Good for | "Remember this" requests | Facts the user never asked to save |
When to give an agent memory tools
- When users ask the assistant to remember or forget something explicitly.
- When the agent should look a fact up only if the question needs it.
- In multi-agent setups, where each agent writes to its own namespace and searches a shared one.
manage_memory descriptions tell the model to save proactively. An agent with this tool may save things you did not intend, like a one-off remark; your system prompt should say what is worth saving.Related
- Previous: Store managers
- Next: Agent memory
- Reference: How to use memory tools
- Update the first memory with
action="update"and its id. - Create the tool with
actions_permitted=("create",)and printsave.args. - Search with a query that shares no meaning with either memory and read the scores.
You understood something today that you didn't yesterday.