Class ReMeLongTermMemory

java.lang.Object
io.agentscope.core.memory.reme.ReMeLongTermMemory
All Implemented Interfaces:
io.agentscope.core.memory.LongTermMemory

public class ReMeLongTermMemory extends Object implements io.agentscope.core.memory.LongTermMemory
Long-term memory implementation using ReMe as the store.

This implementation integrates with ReMe, a memory layer for AI applications that provides persistent, searchable memory storage using LLM-powered memory extraction.

Key Features:

  • LLM-powered memory extraction and inference
  • Workspace-based memory isolation
  • Automatic memory summarization from conversation trajectories
  • Reactive, non-blocking operations

Memory Isolation: Memories are organized by userId (mapped to ReMe's workspace_id), enabling multi-tenant scenarios where different users maintain separate memory contexts.

Usage Example:


 // Create memory instance
 ReMeLongTermMemory memory = ReMeLongTermMemory.builder()
     .userId("task_workspace")
     .apiBaseUrl("http://localhost:8002")
     .build();

 // Use in ReActAgent
 ReActAgent agent = ReActAgent.builder()
     .name("Assistant")
     .model(model)
     .longTermMemory(memory)
     .longTermMemoryMode(LongTermMemoryMode.BOTH)
     .build();
 
See Also:
  • Method Details

    • record

      public reactor.core.publisher.Mono<Void> record(List<io.agentscope.core.message.Msg> msgs)
      Records messages to long-term memory.

      This method converts messages to ReMe trajectory format and sends them to the ReMe API for processing. ReMe will extract and store memorable information from the conversation.

      Only USER and ASSISTANT messages are recorded. For ASSISTANT messages, only those without ToolUseBlock (pure assistant replies) are kept, filtering out tool call requests. TOOL and SYSTEM messages are also filtered out to keep the conversation history clean and focused on user-assistant interactions.

      Messages containing compressed history markers (<compressed_history>) are filtered out to avoid storing redundant compressed information.

      Null messages and messages with empty text content are filtered out before processing. Empty message lists are handled gracefully without error.

      Specified by:
      record in interface io.agentscope.core.memory.LongTermMemory
      Parameters:
      msgs - List of messages to record
      Returns:
      A Mono that completes when recording is finished
    • retrieve

      public reactor.core.publisher.Mono<String> retrieve(io.agentscope.core.message.Msg msg)
      Retrieves relevant memories based on the input message.

      Uses the message content as a query to search for relevant memories in ReMe. Returns memory fragments as a newline-separated string, or empty string if no relevant memories are found.

      Only memories from the configured workspace are returned.

      Specified by:
      retrieve in interface io.agentscope.core.memory.LongTermMemory
      Parameters:
      msg - The message to use as a search query
      Returns:
      A Mono emitting the retrieved memory text (may be empty)
    • builder

      public static ReMeLongTermMemory.Builder builder()
      Creates a new builder for ReMeLongTermMemory.
      Returns:
      A new builder instance