LegacyStateLoader
public final class LegacyStateLoader
io/agentscope/core/state/LegacyStateLoader.java:37–144Legacy 状态加载器,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.core.state 包。核心成员包括 loadFromLegacySession、loadFromLegacySessionWithPresence。
Utility for loading v1 session data into the 2.0 AgentState format.
This class reads the legacy session keys (memory_messages,
toolkit_activeGroups) and constructs an equivalent AgentState object. The
original session data is not modified or migrated in place; subsequent saves will use the new
format automatically.
Legacy keys carry no 2.0-era PermissionContextState, so callers that need a specific
permission context (for example BYPASS for a pre-seeded privileged session) must pass it
in explicitly — otherwise the reconstructed state silently falls back to the default
permission mode.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
LegacyLoadResult | 记录record | 承载 Legacy 加载结果数据的记录类型。 Result of reading the v1 session keys. |
方法摘要Method Summary
方法详情Method Detail
loadFromLegacySession
public static AgentState loadFromLegacySession(AgentStateStore stateStore, String userId, String sessionId)
加载 loadFromLegacySession。
Load an AgentState from a v1 session.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateStore | AgentStateStore | 状态存储到读取来自。the state store to read from |
userId | String | 用户标识(类型 `String`)。nullable user identifier |
sessionId | String | 会话标识(类型 `String`)。the session identifier (required) |
AgentStateio/agentscope/core/state/LegacyStateLoader.java:55–58loadFromLegacySession
public static AgentState loadFromLegacySession(AgentStateStore stateStore, String userId, String sessionId, PermissionContextState permCtx)
加载 loadFromLegacySession。
Load an AgentState from a v1 session, applying the supplied permission context.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateStore | AgentStateStore | 状态存储到读取来自。the state store to read from |
userId | String | 用户标识(类型 `String`)。nullable user identifier |
sessionId | String | 会话标识(类型 `String`)。the session identifier (required) |
permCtx | PermissionContextState | perm Ctx(类型 `PermissionContextState`)。the permission context to attach, or `null` to keep the default |
AgentStateio/agentscope/core/state/LegacyStateLoader.java:74–80loadFromLegacySessionWithPresence
public static LegacyLoadResult loadFromLegacySessionWithPresence(AgentStateStore stateStore, String userId, String sessionId)
加载 loadFromLegacySessionWithPresence。
Loads legacy state without discarding the presence of the singleton tool-group key.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateStore | AgentStateStore | 状态存储(类型 `AgentStateStore`)。The state store. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
LegacyLoadResultio/agentscope/core/state/LegacyStateLoader.java:94–97loadFromLegacySessionWithPresence
public static LegacyLoadResult loadFromLegacySessionWithPresence(AgentStateStore stateStore, String userId, String sessionId, PermissionContextState permCtx)
加载 loadFromLegacySessionWithPresence。
Loads legacy state without discarding the presence of the singleton tool-group key, and applies the supplied permission context to the reconstructed state.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stateStore | AgentStateStore | 状态存储到读取来自。the state store to read from |
userId | String | 用户标识(类型 `String`)。nullable user identifier |
sessionId | String | 会话标识(类型 `String`)。the session identifier (required) |
permCtx | PermissionContextState | perm Ctx(类型 `PermissionContextState`)。the permission context to attach, or `null` to keep the default |
LegacyLoadResultio/agentscope/core/state/LegacyStateLoader.java:113–137嵌套类详情Nested Class Detail
LegacyLoadResult
public record LegacyLoadResult(AgentState state, boolean found)承载 Legacy 加载结果数据的记录类型。位于 io.agentscope.core.state 包。核心成员包括 state、found。
Result of reading the v1 session keys. found is true for non-empty legacy messages or
a present tool-group key, including a tool-group value whose list is explicitly empty.