memoryTools
Returns the tools with which an agent keeps what it learns for its next conversations, in namespace of the Store of the run:
rememberkeeps a text under a short name that the model chooses, such asdiet. Remembering under a name that is already used replaces what was there, so a preference that changes stays one memory.forgetremoves what is kept under a name, for a user who asks the agent to forget it.recalllists what is kept, the last changed first. With aquery, it lists what the query is about instead, the best first, with thesearchof the store: the words of the query in a store of its own, or their meaning in a SemanticStore.
val agent = toolAgent(model, tools = memoryTools(), system = "Remember what the traveller tells you about how they eat.")
agent.invoke(AgentState("I'm piscivegetarian."), GraphConfig(threadId = "plan-7", store = store.within("users", userId)))The tools reach the store through store, so the run needs a GraphConfig.store. With within, the same agent keeps the memories of each user apart. toolLoop runs each call as an effect, so a call that finished is not made again when its step runs again.
To give the model what it remembers without a call to recall, read it in a node before the agent, with store().list(namespace) or store().search(namespace, question), and put it in the first message.
Parameters
where the memories are kept in the store of the run.
how many memories recall lists at most without a query.
how many memories recall lists at most with a query.
Throws
if a part of namespace is empty or a limit is not positive.