Class ReMeLongTermMemory
- All Implemented Interfaces:
io.agentscope.core.memory.LongTermMemory
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:
-
LongTermMemoryReMeClient
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for ReMeLongTermMemory. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReMeLongTermMemory.Builderbuilder()Creates a new builder for ReMeLongTermMemory.reactor.core.publisher.Mono<Void>Records messages to long-term memory.reactor.core.publisher.Mono<String>retrieve(io.agentscope.core.message.Msg msg) Retrieves relevant memories based on the input message.
-
Method Details
-
record
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:
recordin interfaceio.agentscope.core.memory.LongTermMemory- Parameters:
msgs- List of messages to record- Returns:
- A Mono that completes when recording is finished
-
retrieve
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:
retrievein interfaceio.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
Creates a new builder for ReMeLongTermMemory.- Returns:
- A new builder instance
-