Class MemoryFlushManager
java.lang.Object
io.agentscope.harness.agent.memory.MemoryFlushManager
Manages memory flush operations: extracting long-term memories from a conversation
window and appending them to today's daily memory ledger.
Two-layer memory model (this class owns only the first layer):
memory/YYYY-MM-DD.md— append-only daily ledger. Each compaction's flush appends a timestamped section here. Written ONLY by this class.MEMORY.md— globally curated, deduplicated, size-bounded long-term memory. Written ONLY byMemoryConsolidatoron a periodic schedule. Treated as read-only context here.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault prompt for the memory extraction step. -
Constructor Summary
ConstructorsConstructorDescriptionMemoryFlushManager(WorkspaceManager workspaceManager, io.agentscope.core.model.Model model) MemoryFlushManager(WorkspaceManager workspaceManager, io.agentscope.core.model.Model model, String flushPrompt) -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>flushMemories(io.agentscope.core.agent.RuntimeContext rc, List<io.agentscope.core.message.Msg> messages) Extracts long-term memories from messages using the model and writes them to disk.voidoffloadMessages(io.agentscope.core.agent.RuntimeContext rc, List<io.agentscope.core.message.Msg> messages, String agentId, String sessionId) Deprecated.resolveOffloadPath(io.agentscope.core.agent.RuntimeContext rc, String agentId, String sessionId)
-
Field Details
-
DEFAULT_FLUSH_PROMPT
Default prompt for the memory extraction step. Exposed publicly so callers can extend (e.g. append project-specific guidelines) when constructingMemoryConfig.- See Also:
-
-
Constructor Details
-
MemoryFlushManager
-
MemoryFlushManager
public MemoryFlushManager(WorkspaceManager workspaceManager, io.agentscope.core.model.Model model, String flushPrompt) - Parameters:
flushPrompt- SYSTEM prompt for the extraction LLM call.nullfalls back toDEFAULT_FLUSH_PROMPT.
-
-
Method Details
-
flushMemories
public reactor.core.publisher.Mono<Void> flushMemories(io.agentscope.core.agent.RuntimeContext rc, List<io.agentscope.core.message.Msg> messages) Extracts long-term memories from messages using the model and writes them to disk.Provides existing MEMORY.md and today's daily file content to the extraction LLM so it can effectively deduplicate and avoid re-extracting known facts.
-
resolveOffloadPath
@Deprecated public String resolveOffloadPath(io.agentscope.core.agent.RuntimeContext rc, String agentId, String sessionId) Deprecated.Returns the string path of the session JSONL file where messages for the given agent and session are offloaded. Used by the compaction layer to embed the archive location in the summary message so the agent can retrieve full history if needed. -
offloadMessages
@Deprecated public void offloadMessages(io.agentscope.core.agent.RuntimeContext rc, List<io.agentscope.core.message.Msg> messages, String agentId, String sessionId) Deprecated.PreferSessionTranscriptWriter.appendMessages(io.agentscope.core.agent.RuntimeContext, java.util.List<io.agentscope.core.message.Msg>, java.lang.String, java.lang.String). Kept as a thin delegate so compaction / overflow-recovery call sites keep compiling during the migration; new code should useSessionTranscriptWriterdirectly.Offloads raw messages to the JSONL session tree.
-
SessionTranscriptWriter.appendMessages(io.agentscope.core.agent.RuntimeContext, java.util.List<io.agentscope.core.message.Msg>, java.lang.String, java.lang.String).