Annotation Interface Memory
Defines conversation memory, vector memory, and persistence settings for maintaining agent state across interactions.
Consolidation lifecycle (TAN-5049)
When Memory.Conversation.enabled() is true (the default), the framework
creates a MemoryConsolidationPipeline for the agent
during initialization and drives it from the agent lifecycle:
Agent.stop() triggers a final consolidation pass
via onSessionEnd(). The pipeline is exposed through
Agent.getConsolidationPipeline() — periodic
auto-consolidation is NOT started automatically (no interval is configured
here); call startAutoConsolidation(Duration) on the pipeline if
time-based consolidation is desired.
Usage
@Memory(
conversation = @Conversation(maxMessages = 100, strategy = Strategy.SLIDING_WINDOW),
vector = @Vector(dimensions = 1536, provider = "pinecone", index = "agent-memory"),
persistence = @Persistence(store = "redis", ttlSeconds = 86400)
)
public class ResearchAgent extends Agent { ... }
- Author:
- TnsAI Team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceConversation memory configuration.static @interfaceState persistence configuration.static @interfaceVector memory configuration. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionConversation memory configuration.Memory namespace/scope.State persistence configuration.booleanWhether to enable memory across sessions.booleanWhether to share memory with other agents.String[]Agent IDs to share memory with.Vector memory configuration.
-
Element Details
-
conversation
Memory.Conversation conversationConversation memory configuration.When
Memory.Conversation.enabled()is true, a consolidation pipeline is created and wired into the agent lifecycle: a final consolidation runs onAgent.stop(), and the pipeline is available viaAgent.getConsolidationPipeline()for manual or scheduled use.- Returns:
- conversation settings
- Default:
@com.tnsai.annotations.Memory.Conversation
-
vector
Memory.Vector vectorVector memory configuration.- Returns:
- vector memory settings
- Default:
@com.tnsai.annotations.Memory.Vector
-
persistence
Memory.Persistence persistenceState persistence configuration.- Returns:
- persistence settings
- Default:
@com.tnsai.annotations.Memory.Persistence
-
persistent
boolean persistentWhether to enable memory across sessions.- Returns:
- true for persistent memory
- Default:
false
-
namespace
String namespaceMemory namespace/scope.Isolates memory between different contexts.
When combined with
shared(), an explicit namespace always wins: agents sharing memory must declare the same namespace (or be routed to it viashareWith()). When left empty, the effective shared namespace is resolved byAgentMemoryResolver: the agent joins a namespace it was granted access to via another agent'sshareWithlist, or falls back to the global default namespace"shared".- Returns:
- namespace name
- Default:
""
-