LangMemLangMem 0.0.30 · LangGraph 1.2 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
19 small wins to finish your pathNext lesson →

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:

python
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.

python
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.

python
asha = {"configurable": {"user_id": "asha"}}
save.invoke({"content": "Order A-1001 arrived broken", "action": "create"}, config=asha)

Saving and searching with the tools

ExampleAPI key
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"])

What the tools returned

  • The tools' arguments are what an agent fills in: content, action and id for manage_memory; query, limit, offset and filter for search_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 toolsStore manager
Who decides what to saveThe agent, during the chatA separate model call after the chat
Effect on the replyExtra tool calls before the answerNone, if run in the background
Good for"Remember this" requestsFacts 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.
Watch out. 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.
Try it yourself
  • Update the first memory with action="update" and its id.
  • Create the tool with actions_permitted=("create",) and print save.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.