AgentStateMemoryView
@Deprecated(forRemoval = true, since = "2.0.0") public final class AgentStateMemoryView implements Memory
io/agentscope/core/memory/AgentStateMemoryView.java:42–86智能体状态记忆 View,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.core.memory 包,实现 Memory。核心成员包括 getMessages、addMessage、deleteMessage、clear、saveTo、loadFrom。
Read-only Memory adapter that proxies #getMessages() to a live
AgentState#getContext() resolved at call time.
Exists solely so deprecated 1.x hooks and tools (notably
StaticLongTermMemoryHook) keep working after the 2.0 builder dropped agent-owned
Memory. All mutating operations throw UnsupportedOperationException; mutate
context via AgentState.context instead.
The Supplier contract is "best-effort": a null return is interpreted as
"agent not yet bound" and surfaces as an empty message list rather than an exception, so
callers may instantiate the view before the owning io.agentscope.core.ReActAgent is
constructed.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public AgentStateMemoryView(Supplier<AgentState> stateSupplier) | 初始化 `AgentStateMemoryView` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public List<Msg> getMessages() | 获取消息。 Returns the messages. |
public void addMessage(Msg message) | 添加消息。 Adds the message. |
public void deleteMessage(int index) | 删除消息。 Deletes the message. |
public void clear() | 清空或重置内部状态。 Clears or resets internal state. |
public void saveTo(AgentStateStore stateStore, String userId, String sessionId) | 保存到。 Saves the to. |
public void loadFrom(AgentStateStore stateStore, String userId, String sessionId) | 加载来自。 Loads the from. |
构造器详情Constructor Detail
AgentStateMemoryView
public AgentStateMemoryView(Supplier<AgentState> stateSupplier)
初始化 AgentStateMemoryView 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateSupplier | Supplier<AgentState> | 状态 Supplier(类型 `Supplier`)。The state supplier. |
io/agentscope/core/memory/AgentStateMemoryView.java:47–49方法详情Method Detail
getMessages
public List<Msg> getMessages()
获取消息。
Returns the messages.
List<Msg>io/agentscope/core/memory/AgentStateMemoryView.java:51–55addMessage
public void addMessage(Msg message)
添加消息。
Adds the message.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Msg | 消息(类型 `Msg`)。The message. |
io/agentscope/core/memory/AgentStateMemoryView.java:57–60deleteMessage
public void deleteMessage(int index)
删除消息。
Deletes the message.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
index | int | 索引(类型 `int`)。The index. |
io/agentscope/core/memory/AgentStateMemoryView.java:62–65clear
public void clear()
清空或重置内部状态。
Clears or resets internal state.
io/agentscope/core/memory/AgentStateMemoryView.java:67–70saveTo
public void saveTo(AgentStateStore stateStore, String userId, String sessionId)
保存到。
Saves the to.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateStore | AgentStateStore | 状态存储(类型 `AgentStateStore`)。The state store. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/core/memory/AgentStateMemoryView.java:72–75loadFrom
public void loadFrom(AgentStateStore stateStore, String userId, String sessionId)
加载来自。
Loads the from.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateStore | AgentStateStore | 状态存储(类型 `AgentStateStore`)。The state store. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/core/memory/AgentStateMemoryView.java:77–80