Record Class MemoryConfig

java.lang.Object
java.lang.Record
com.tnsai.memory.MemoryConfig
Record Components:
type - store flavour (conversation / vector / hybrid / …)
capacity - max retained entries (0 = unbounded; every positive value, including the default 100, is enforced)
pruneStrategy - how entries are evicted at capacity
persistence - backing store (in-memory / redis / database / file)
maxContextTokens - token budget; > 0 wraps the store as token-aware
includeSystemMessages - whether system messages count toward history
summarizeOnPrune - summarise rather than drop pruned entries
connectionUrl - backend connection string (for redis/database/file)

public record MemoryConfig(MemorySpec.MemoryType type, int capacity, MemorySpec.PruneStrategy pruneStrategy, MemorySpec.Persistence persistence, int maxContextTokens, boolean includeSystemMessages, boolean summarizeOnPrune, String connectionUrl) extends Record
Programmatic form of the @MemorySpec annotation — the builder-path counterpart that closes the @MemorySpec parity gap (TNS-546). Mirrors the annotation's eight fields 1:1 so a builder user gets the same declarative memory configuration without hand-building a MemoryStore or knowing the per-store implementation classes.

Feeds the same MemoryStoreFactory as the annotation path: the annotation is adapted via from(MemorySpec), and AgentBuilder.memoryConfig(...) resolves a config into a store through MemoryStoreFactory.create(MemoryConfig).

Since:
0.12.0 (TNS-546)
  • Constructor Details

  • Method Details

    • from

      public static MemoryConfig from(MemorySpec annotation)
      Adapts a @MemorySpec annotation into a config (the annotation path).
    • defaults

      public static MemoryConfig defaults()
      The defaults of a bare @MemorySpec() — conversation, capacity 100, sliding-window, in-memory.
    • builder

      public static MemoryConfig.Builder builder()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public MemorySpec.MemoryType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • capacity

      public int capacity()
      Returns the value of the capacity record component.
      Returns:
      the value of the capacity record component
    • pruneStrategy

      public MemorySpec.PruneStrategy pruneStrategy()
      Returns the value of the pruneStrategy record component.
      Returns:
      the value of the pruneStrategy record component
    • persistence

      public MemorySpec.Persistence persistence()
      Returns the value of the persistence record component.
      Returns:
      the value of the persistence record component
    • maxContextTokens

      public int maxContextTokens()
      Returns the value of the maxContextTokens record component.
      Returns:
      the value of the maxContextTokens record component
    • includeSystemMessages

      public boolean includeSystemMessages()
      Returns the value of the includeSystemMessages record component.
      Returns:
      the value of the includeSystemMessages record component
    • summarizeOnPrune

      public boolean summarizeOnPrune()
      Returns the value of the summarizeOnPrune record component.
      Returns:
      the value of the summarizeOnPrune record component
    • connectionUrl

      public String connectionUrl()
      Returns the value of the connectionUrl record component.
      Returns:
      the value of the connectionUrl record component