MemoryBounds

org.llm4s.agent.memory.MemoryBounds
See theMemoryBounds companion object
@Experimental
final case class MemoryBounds

How much one store may hold: at most maxMemories memories and maxBytes bytes, measured by MemoryBounds.sizeOf. A TransactionalMemoryStore enforces both in the transaction that adds, by evicting.

The bounds count, and eviction ranks, every memory in the store, whoever stored it - unless an MemoryBounds.Owner is set (withOwner): then only the memories whose metadata carries the owner's key and value count, and only they are ever evicted. A writer that shares a store with data it did not write (knowledge loaded with recordKnowledge, facts an application stores) sets one, as SemanticMemoryMiddleware does (#3034).

Attributes

Companion
object
Source
TransactionalMemoryStore.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def counts(metadata: Map[String, String]): Boolean

Whether a memory with metadata counts toward these bounds, and so may be evicted.

Whether a memory with metadata counts toward these bounds, and so may be evicted.

Attributes

Source
TransactionalMemoryStore.scala
def overflow(entries: Seq[Entry]): Vector[MemoryId]

The memories to evict from entries - (id, importance, timestamp, size) - so that the rest are within both bounds: lowest importance first (a memory with none counts as 0.5), then oldest, then by id, compared by its UTF-8 bytes as recall and the SQL stores compare ids. entries are the memories that counts: a store passes only those. The SQL stores rank and delete in one statement instead, in this order (#3328).

The memories to evict from entries - (id, importance, timestamp, size) - so that the rest are within both bounds: lowest importance first (a memory with none counts as 0.5), then oldest, then by id, compared by its UTF-8 bytes as recall and the SQL stores compare ids. entries are the memories that counts: a store passes only those. The SQL stores rank and delete in one statement instead, in this order (#3328).

Attributes

Source
TransactionalMemoryStore.scala
def withOwner(key: String, value: String): MemoryBounds

These bounds counting only the memories whose metadata has key set to value.

These bounds counting only the memories whose metadata has key set to value.

Attributes

Source
TransactionalMemoryStore.scala

These bounds counting only owner's memories, or every memory for None.

These bounds counting only owner's memories, or every memory for None.

Attributes

Source
TransactionalMemoryStore.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product