接口 Memory
- 所有已知实现类:
AgentStateMemoryView,InMemoryMemory,StateBackedMemory
Different memory implementations can provide various storage strategies such as in-memory,
database-backed, or window-based storage. saveTo(io.agentscope.core.state.AgentStateStore, java.lang.String, java.lang.String) / loadFrom(io.agentscope.core.state.AgentStateStore, java.lang.String, java.lang.String) let callers
persist the message buffer through a AgentStateStore for legacy v1 sessions; new code should
use AgentState instead.
-
方法概要
修饰符和类型方法说明voidaddMessage(Msg message) 已过时, 待删除: 此 API 元素将从以后的版本中删除。Adds a message to the memory.voidclear()已过时, 待删除: 此 API 元素将从以后的版本中删除。Clears all messages from memory.voiddeleteMessage(int index) 已过时, 待删除: 此 API 元素将从以后的版本中删除。Deletes a message at the specified index.已过时, 待删除: 此 API 元素将从以后的版本中删除。Retrieves all messages stored in memory.voidloadFrom(AgentStateStore stateStore, String userId, String sessionId) 已过时, 待删除: 此 API 元素将从以后的版本中删除。Load a previously saved message buffer (no-op when none exists).voidsaveTo(AgentStateStore stateStore, String userId, String sessionId) 已过时, 待删除: 此 API 元素将从以后的版本中删除。Save the message buffer under thememory_messagessession key.
-
方法详细资料
-
saveTo
已过时, 待删除: 此 API 元素将从以后的版本中删除。Save the message buffer under thememory_messagessession key. -
loadFrom
已过时, 待删除: 此 API 元素将从以后的版本中删除。Load a previously saved message buffer (no-op when none exists). -
addMessage
已过时, 待删除: 此 API 元素将从以后的版本中删除。Adds a message to the memory.- 参数:
message- The message to store in memory
-
getMessages
已过时, 待删除: 此 API 元素将从以后的版本中删除。Retrieves all messages stored in memory.- 返回:
- A list of all messages (may be empty but never null)
-
deleteMessage
void deleteMessage(int index) 已过时, 待删除: 此 API 元素将从以后的版本中删除。Deletes a message at the specified index.If the index is out of bounds (negative or >= size), this operation should be a no-op rather than throwing an exception. This provides safe cleanup even with concurrent modifications.
- 参数:
index- The index of the message to delete (0-based)
-
clear
void clear()已过时, 待删除: 此 API 元素将从以后的版本中删除。Clears all messages from memory.This operation removes all stored conversation history. Use with caution as this action is typically irreversible unless state has been persisted.
-
AgentState.getContext(). This interface is retained as a write-only mirror for source compatibility with 1.0.x user code.