Store
Keeps what an agent learned between conversations: a preference of a user, a fact, an earlier decision. A Checkpointer saves the state of one thread; a store belongs to no thread, so every run that is given the same store reads what the others wrote.
A value is text under a namespace and a key. The namespace is a list of names, such as listOf("users", userId, "preferences"), and list finds everything under a part of it, such as listOf("users", userId). The overloads with a StateSerializer keep other types, and with telar-serialization a @Serializable type needs none.
val store = MemoryStore()
val graph = StateGraph<Trip> {
val plan = node("plan") { trip ->
val diet = store().get(listOf("preferences"), "diet")?.value
trip.copy(diet = diet)
}
START then plan then END
}.compile()
graph.invoke(trip, GraphConfig(threadId = "plan-7", store = store.within("users", userId)))Give it to a run with GraphConfig.store, and a node or a tool reaches it with store. within gives each user a part of the store of their own.
A write goes straight to the store, and is not part of a checkpoint. When a step runs again, its nodes write again: a put under the same key leaves the value of the last try, which is the try whose state the run continues with. A node that reads a value and writes one made from it, such as a counter, uses effect, as it would with any other service. A step that fails and is never resumed keeps what it wrote.
search finds the items that a query is about. Here it looks for the words of the query; a store that ranks by meaning, such as SemanticStore of telar-agent, replaces it.
Every implementation checks what it is given with checkAddress, checkNamespace and checkLimit, as MemoryStore does: a key and each part of a namespace are not empty, and a limit is positive.