Package com.tnsai.memory
Class MemoryStoreFactory
java.lang.Object
com.tnsai.memory.MemoryStoreFactory
Factory for creating MemoryStore instances based on
MemorySpec annotation.
This factory enables annotation-driven memory configuration, creating the appropriate memory store implementation based on annotation parameters.
Supported Configurations
- type: CONVERSATION, VECTOR, HYBRID, WORKING, EPISODIC
- capacity: Maximum number of messages (0 = unbounded; the default of 100 is a real, enforced limit)
- pruneStrategy: SLIDING_WINDOW, RELEVANCE, SUMMARIZE, TOKEN_LIMIT, NONE
- persistence: IN_MEMORY, REDIS, DATABASE, FILE
- maxContextTokens: Token limit for context window
Usage Example
// From annotation
MemorySpec config = agentClass.getAnnotation(MemorySpec.class);
MemoryStore store = MemoryStoreFactory.create(config);
// With defaults
MemoryStore defaultStore = MemoryStoreFactory.createDefault();
- Author:
- TnsAI Team
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryStorecreate(MemorySpec config) Creates a MemoryStore based on the given@MemorySpecannotation.static MemoryStorecreate(MemoryConfig config) Creates a MemoryStore from a programmaticMemoryConfig— the canonical factory both the annotation path (create(MemorySpec)) andAgentBuilder.memoryConfig(...)flow through (TNS-546).static MemoryStoreCreates a default MemoryStore (in-memory, no limits).
-
Method Details
-
create
Creates a MemoryStore based on the given@MemorySpecannotation. Delegates tocreate(MemoryConfig)viaMemoryConfig.from(MemorySpec)so the annotation and programmatic paths share one codepath (TNS-546).- Parameters:
config- the MemorySpec annotation- Returns:
- configured MemoryStore instance
-
create
Creates a MemoryStore from a programmaticMemoryConfig— the canonical factory both the annotation path (create(MemorySpec)) andAgentBuilder.memoryConfig(...)flow through (TNS-546).- Parameters:
config- the memory configuration- Returns:
- configured MemoryStore instance
-
createDefault
Creates a default MemoryStore (in-memory, no limits).- Returns:
- default InMemoryStore
-