memoryTools

fun memoryTools(namespace: List<String> = listOf("memories"), limit: Int = Store.DEFAULT_LIMIT, searchLimit: Int = Store.DEFAULT_SEARCH_LIMIT): List<Tool>

Returns the tools with which an agent keeps what it learns for its next conversations, in namespace of the Store of the run:

  • remember keeps a text under a short name that the model chooses, such as diet. Remembering under a name that is already used replaces what was there, so a preference that changes stays one memory.

  • forget removes what is kept under a name, for a user who asks the agent to forget it.

  • recall lists what is kept, the last changed first. With a query, it lists what the query is about instead, the best first, with the search of 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

namespace

where the memories are kept in the store of the run.

limit

how many memories recall lists at most without a query.

searchLimit

how many memories recall lists at most with a query.

Throws

if a part of namespace is empty or a limit is not positive.