Package com.tnsai.memory
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 capacitypersistence- backing store (in-memory / redis / database / file)maxContextTokens- token budget;> 0wraps the store as token-awareincludeSystemMessages- whether system messages count toward historysummarizeOnPrune- summarise rather than drop pruned entriesconnectionUrl- 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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder for the programmatic path. -
Constructor Summary
ConstructorsConstructorDescriptionMemoryConfig(MemorySpec.MemoryType type, int capacity, MemorySpec.PruneStrategy pruneStrategy, MemorySpec.Persistence persistence, int maxContextTokens, boolean includeSystemMessages, boolean summarizeOnPrune, String connectionUrl) Creates an instance of aMemoryConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryConfig.Builderbuilder()intcapacity()Returns the value of thecapacityrecord component.Returns the value of theconnectionUrlrecord component.static MemoryConfigdefaults()The defaults of a bare@MemorySpec()— conversation, capacity 100, sliding-window, in-memory.final booleanIndicates whether some other object is "equal to" this one.static MemoryConfigfrom(MemorySpec annotation) Adapts a@MemorySpecannotation into a config (the annotation path).final inthashCode()Returns a hash code value for this object.booleanReturns the value of theincludeSystemMessagesrecord component.intReturns the value of themaxContextTokensrecord component.Returns the value of thepersistencerecord component.Returns the value of thepruneStrategyrecord component.booleanReturns the value of thesummarizeOnPrunerecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
MemoryConfig
public MemoryConfig(MemorySpec.MemoryType type, int capacity, MemorySpec.PruneStrategy pruneStrategy, MemorySpec.Persistence persistence, int maxContextTokens, boolean includeSystemMessages, boolean summarizeOnPrune, String connectionUrl) Creates an instance of aMemoryConfigrecord class.- Parameters:
type- the value for thetyperecord componentcapacity- the value for thecapacityrecord componentpruneStrategy- the value for thepruneStrategyrecord componentpersistence- the value for thepersistencerecord componentmaxContextTokens- the value for themaxContextTokensrecord componentincludeSystemMessages- the value for theincludeSystemMessagesrecord componentsummarizeOnPrune- the value for thesummarizeOnPrunerecord componentconnectionUrl- the value for theconnectionUrlrecord component
-
-
Method Details
-
from
Adapts a@MemorySpecannotation into a config (the annotation path). -
defaults
The defaults of a bare@MemorySpec()— conversation, capacity 100, sliding-window, in-memory. -
builder
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
capacity
public int capacity()Returns the value of thecapacityrecord component.- Returns:
- the value of the
capacityrecord component
-
pruneStrategy
Returns the value of thepruneStrategyrecord component.- Returns:
- the value of the
pruneStrategyrecord component
-
persistence
Returns the value of thepersistencerecord component.- Returns:
- the value of the
persistencerecord component
-
maxContextTokens
public int maxContextTokens()Returns the value of themaxContextTokensrecord component.- Returns:
- the value of the
maxContextTokensrecord component
-
includeSystemMessages
public boolean includeSystemMessages()Returns the value of theincludeSystemMessagesrecord component.- Returns:
- the value of the
includeSystemMessagesrecord component
-
summarizeOnPrune
public boolean summarizeOnPrune()Returns the value of thesummarizeOnPrunerecord component.- Returns:
- the value of the
summarizeOnPrunerecord component
-
connectionUrl
Returns the value of theconnectionUrlrecord component.- Returns:
- the value of the
connectionUrlrecord component
-