Annotation Interface MemorySpec


@Documented @Retention(RUNTIME) @Target({}) public @interface MemorySpec
Memory configuration annotation for Agents.

Defines how the agent manages conversation history and knowledge.

Usage


 @AgentSpec(description = "Research assistant")
 @MemorySpec(
     type = MemoryType.CONVERSATION,
     capacity = 100,
     pruneStrategy = PruneStrategy.SLIDING_WINDOW
 )
 public class ResearchAgent extends Agent { ... }
 
Author:
TnsAI Team
  • Element Details

    • type

      Type of memory store.
      Default:
      CONVERSATION
    • capacity

      int capacity
      Maximum number of messages/items to store.

      The default of 100 is a real, enforced limit — a bare @MemorySpec prunes at 100 entries. Set to 0 for unbounded storage.

      Default:
      100
    • pruneStrategy

      Strategy for pruning when capacity is exceeded.
      Default:
      SLIDING_WINDOW
    • persistence

      Persistence backend.
      Default:
      IN_MEMORY
    • maxContextTokens

      int maxContextTokens
      Maximum tokens for context window management.

      0 = no limit.

      Default:
      0
    • includeSystemMessages

      boolean includeSystemMessages
      Whether to include system messages in history.
      Default:
      false
    • summarizeOnPrune

      boolean summarizeOnPrune
      Whether to summarize old messages instead of removing.
      Default:
      false
    • connectionUrl

      String connectionUrl
      Redis/Database connection URL (for persistent storage).
      Default:
      ""