MemorySaveTool
public class MemorySaveTool
源码Source
io/agentscope/harness/agent/tool/MemorySaveTool.java:40–88记忆保存工具,封装可被智能体调用的能力。位于 io.agentscope.harness.agent.tool 包。核心成员包括 memorySave、MemorySaveTool。
Dedicated tool for persisting user memories to both MEMORY.md and
today's daily ledger (memory/YYYY-MM-DD.md).
This is the only sanctioned entry point for the agent to write long-term
memories. The system prompt directs the LLM to use this tool instead of
write_file/edit_file on memory paths, eliminating the
non-determinism of the LLM choosing arbitrary file names or skipping the
daily ledger.
Writes are append-only; deduplication and size-trimming are handled by the
periodic io.agentscope.harness.agent.memory.MemoryConsolidator.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public MemorySaveTool(WorkspaceManager workspaceManager) | 初始化 `MemorySaveTool` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String memorySave(RuntimeContext runtimeContext, String content) | 执行记忆保存相关操作。 Performs the memory save operation. |
构造器详情Constructor Detail
MemorySaveTool
public MemorySaveTool(WorkspaceManager workspaceManager)
初始化 MemorySaveTool 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceManager | WorkspaceManager | 工作区管理器(类型 `WorkspaceManager`)。The workspace manager. |
源码Source
io/agentscope/harness/agent/tool/MemorySaveTool.java:44–46方法详情Method Detail
memorySave
public String memorySave(RuntimeContext runtimeContext, String content)
执行记忆保存相关操作。
Performs the memory save operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
content | String | 内容(类型 `String`)。The content. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/MemorySaveTool.java:48–87