AS AgentScopeAPI 手册 / API Reference

InMemoryMemory

@Deprecated(forRemoval = true, since = "2.0.0") public class InMemoryMemory implements Memory
源码Source io/agentscope/core/memory/InMemoryMemory.java:36–134

In 记忆记忆,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.core.memory 包,实现 Memory。核心成员包括 saveTo、loadFrom、addMessage、getMessages、deleteMessage、clear。

In-memory implementation of Memory with state persistence support.

This implementation stores messages in memory using thread-safe collections and provides state serialization/deserialization for session management.

构造器摘要Constructor Summary

构造器Constructor说明Description
public InMemoryMemory()
初始化 `InMemoryMemory` 实例。
Constructor for InMemoryMemory.

方法摘要Method Summary

方法Method说明Description
public void saveTo(AgentStateStore stateStore, String userId, String sessionId)
保存到。
Save memory state to the session.
public void loadFrom(AgentStateStore stateStore, String userId, String sessionId)
加载来自。
Load memory state from the store.
public void addMessage(Msg message)
添加消息。
Adds a message to the in-memory message list.
public List<Msg> getMessages()
获取消息。
Retrieves all non-null messages from memory.
public void deleteMessage(int index)
删除消息。
Deletes a message at the specified index.
public void clear()
清空或重置内部状态。
Clears all messages from memory.

构造器详情Constructor Detail

InMemoryMemory

public InMemoryMemory()

初始化 InMemoryMemory 实例。

Constructor for InMemoryMemory.

源码Source io/agentscope/core/memory/InMemoryMemory.java:47

方法详情Method Detail

saveTo

public void saveTo(AgentStateStore stateStore, String userId, String sessionId)

保存到。

Save memory state to the session.

参数Parameters
名称Name类型Type说明Description
stateStoreAgentStateStore状态存储到保存到。the state store to save to
userIdString用户标识(类型 `String`)。the user identifier
sessionIdString会话标识(类型 `String`)。the session identifier
源码Source io/agentscope/core/memory/InMemoryMemory.java:62–66

loadFrom

public void loadFrom(AgentStateStore stateStore, String userId, String sessionId)

加载来自。

Load memory state from the store.

参数Parameters
名称Name类型Type说明Description
stateStoreAgentStateStore状态存储到加载来自。the state store to load from
userIdString用户标识(类型 `String`)。nullable user identifier
sessionIdString会话标识(类型 `String`)。session identifier
源码Source io/agentscope/core/memory/InMemoryMemory.java:75–81

addMessage

public void addMessage(Msg message)

添加消息。

Adds a message to the in-memory message list.

参数Parameters
名称Name类型Type说明Description
messageMsg消息到添加到记忆。The message to add to memory
源码Source io/agentscope/core/memory/InMemoryMemory.java:92–95

getMessages

public List<Msg> getMessages()

获取消息。

Retrieves all non-null messages from memory.

返回Returns List<Msg>
返回列出。A new list containing all non-null messages
源码Source io/agentscope/core/memory/InMemoryMemory.java:105–108

deleteMessage

public void deleteMessage(int index)

删除消息。

Deletes a message at the specified index.

参数Parameters
名称Name类型Type说明Description
indexint索引(类型 `int`)。The index of the message to delete (0-based)
源码Source io/agentscope/core/memory/InMemoryMemory.java:118–123

clear

public void clear()

清空或重置内部状态。

Clears all messages from memory.

源码Source io/agentscope/core/memory/InMemoryMemory.java:130–133
基于官方固定版本源码静态生成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.