AS AgentScopeAPI 手册 / API Reference

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
workspaceManagerWorkspaceManager工作区管理器(类型 `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
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
contentString内容(类型 `String`)。The content.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/MemorySaveTool.java:48–87
基于官方固定版本源码静态生成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.