MemoryFlushManager
public class MemoryFlushManager
io/agentscope/harness/agent/memory/MemoryFlushManager.java:53–362记忆刷新管理器,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.harness.agent.memory 包。核心成员包括 flushMemories、resolveOffloadPath、offloadMessages、MemoryFlushManager、DEFAULT_FLUSH_PROMPT。
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
| 字段Field | 类型Type | 说明Description |
|---|---|---|
DEFAULT_FLUSH_PROMPTstaticfinal | String | 默认刷新提示词字段。 Default prompt for the memory extraction step. |
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<Void> flushMemories(RuntimeContext rc, List<Msg> messages) | 执行 `flushMemories` 方法。 Extracts long-term memories from messages using the model and writes them to disk. |
public String resolveOffloadPath(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. |
public void offloadMessages(RuntimeContext rc, List<Msg> messages, String agentId, String sessionId)deprecated | 执行卸载消息相关操作。 Offloads raw messages to the JSONL session tree. |
字段详情Field Detail
DEFAULT_FLUSH_PROMPT
public static final String DEFAULT_FLUSH_PROMPT
默认刷新提示词字段。声明为 public static final String DEFAULT_FLUSH_PROMPT。
Default prompt for the memory extraction step.
io/agentscope/harness/agent/memory/MemoryFlushManager.java:62–89构造器详情Constructor Detail
MemoryFlushManager
public MemoryFlushManager(WorkspaceManager workspaceManager, Model model)
初始化 MemoryFlushManager 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceManager | WorkspaceManager | 工作区管理器(类型 `WorkspaceManager`)。The workspace manager. |
model | Model | 模型实例(类型 `Model`)。The model. |
io/agentscope/harness/agent/memory/MemoryFlushManager.java:95–97MemoryFlushManager
public MemoryFlushManager(WorkspaceManager workspaceManager, Model model, String flushPrompt)
初始化 MemoryFlushManager 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceManager | WorkspaceManager | 工作区管理器(类型 `WorkspaceManager`)。The workspace manager. |
model | Model | 模型实例(类型 `Model`)。The model. |
flushPrompt | String | 刷新提示词(类型 `String`)。SYSTEM prompt for the extraction LLM call. `null` falls back to `#DEFAULT_FLUSH_PROMPT`. |
io/agentscope/harness/agent/memory/MemoryFlushManager.java:103–107方法详情Method Detail
flushMemories
public Mono<Void> flushMemories(RuntimeContext rc, List<Msg> messages)
执行 flushMemories 方法。
Extracts long-term memories from messages using the model and writes them to disk.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Void>io/agentscope/harness/agent/memory/MemoryFlushManager.java:115–184resolveOffloadPath
public String resolveOffloadPath(RuntimeContext rc, String agentId, String sessionId)
解析卸载路径。
Returns the string path of the session JSONL file where messages for the given agent and session are offloaded.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
Stringio/agentscope/harness/agent/memory/MemoryFlushManager.java:193–197offloadMessages
public void offloadMessages(RuntimeContext rc, List<Msg> messages, String agentId, String sessionId)
执行卸载消息相关操作。
Offloads raw messages to the JSONL session tree.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/harness/agent/memory/MemoryFlushManager.java:206–216