AS AgentScopeAPI 手册 / API Reference

MemoryFlushManager

public class MemoryFlushManager
源码Source 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 by MemoryConsolidator on a periodic schedule. Treated as read-only context here.

字段摘要Field Summary

字段Field类型Type说明Description
DEFAULT_FLUSH_PROMPT
staticfinal
String
默认刷新提示词字段。
Default prompt for the memory extraction step.

构造器摘要Constructor Summary

构造器Constructor说明Description
public MemoryFlushManager(WorkspaceManager workspaceManager, Model model)
初始化 `MemoryFlushManager` 实例。
Creates a new instance.
public MemoryFlushManager(WorkspaceManager workspaceManager, Model model, String flushPrompt)
初始化 `MemoryFlushManager` 实例。
Creates a new instance.

方法摘要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
staticfinal

默认刷新提示词字段。声明为 public static final String DEFAULT_FLUSH_PROMPT。

Default prompt for the memory extraction step.

源码Source io/agentscope/harness/agent/memory/MemoryFlushManager.java:62–89

构造器详情Constructor Detail

MemoryFlushManager

public MemoryFlushManager(WorkspaceManager workspaceManager, Model model)

初始化 MemoryFlushManager 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
workspaceManagerWorkspaceManager工作区管理器(类型 `WorkspaceManager`)。The workspace manager.
modelModel模型实例(类型 `Model`)。The model.
源码Source io/agentscope/harness/agent/memory/MemoryFlushManager.java:95–97

MemoryFlushManager

public MemoryFlushManager(WorkspaceManager workspaceManager, Model model, String flushPrompt)

初始化 MemoryFlushManager 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
workspaceManagerWorkspaceManager工作区管理器(类型 `WorkspaceManager`)。The workspace manager.
modelModel模型实例(类型 `Model`)。The model.
flushPromptString刷新提示词(类型 `String`)。SYSTEM prompt for the extraction LLM call. `null` falls back to `#DEFAULT_FLUSH_PROMPT`.
源码Source 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.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
messagesList<Msg>消息列表(类型 `List`)。The messages.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/memory/MemoryFlushManager.java:115–184

resolveOffloadPath

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.

已弃用。Deprecated. 已弃用,请改用受支持的替代 API。Prefer `SessionTranscriptWriter#resolveContextPath`.
参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
agentIdString智能体标识(类型 `String`)。The agent id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/memory/MemoryFlushManager.java:193–197

offloadMessages

public void offloadMessages(RuntimeContext rc, List<Msg> messages, String agentId, String sessionId)
deprecated

执行卸载消息相关操作。

Offloads raw messages to the JSONL session tree.

已弃用。Deprecated. 已弃用,请改用受支持的替代 API。Prefer `SessionTranscriptWriter#appendMessages`. Kept as a thin delegate so compaction / overflow-recovery call sites keep compiling during the migration; new code should use `SessionTranscriptWriter` directly.
参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
messagesList<Msg>消息列表(类型 `List`)。The messages.
agentIdString智能体标识(类型 `String`)。The agent id.
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/harness/agent/memory/MemoryFlushManager.java:206–216
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.