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

Memory tools: manage and search

create_manage_memory_tool and create_search_memory_tool give an agent memory as tools: it decides during the conversation what to save and when to look.

Example
save = create_manage_memory_tool(namespace=("memories", "{user_id}"), store=store)
print(save.name, "|", save.description.splitlines()[0])
print(list(save.args))

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

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. Invoking it directly, as here, does what an agent's call would do, and returns the text the agent reads back, with the new memory's id.

Example
find = create_search_memory_tool(namespace=("memories", "{user_id}"), store=store)
results = json.loads(find.invoke({"query": "broken order"}, config=asha))
for row in results:
    print(row["value"], round(row["score"], 3))

search_memory returns JSON the model reads: each item with its namespace, key, value, timestamps and score, best match first.

Hot path or background

Memory toolsStore manager
Who decidesThe agent, during the chatA separate call after the chat
LatencyAdds tool calls to the replyNone for the user, if run in the background
Good for"Remember this" requestsPicking up what the user did not ask to save
Try it yourself
  • Update the saved memory with action="update" and its id.
  • Create the tool with actions_permitted=("create",) and print its args.
  • Search with a query that shares no words with either memory.

You understood something today that you didn't yesterday.