AS AgentScopeAPI 手册 / API Reference

LegacyStateLoader

public final class LegacyStateLoader
源码Source io/agentscope/core/state/LegacyStateLoader.java:37–144

Legacy 状态加载器,在多次调用之间保存和恢复会话与记忆数据。位于 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说明Description
public static AgentState loadFromLegacySession(AgentStateStore stateStore, String userId, String sessionId)
static
加载 `loadFromLegacySession`。
Load an `AgentState` from a v1 session.
public static AgentState loadFromLegacySession(AgentStateStore stateStore, String userId, String sessionId, PermissionContextState permCtx)
static
加载 `loadFromLegacySession`。
Load an `AgentState` from a v1 session, applying the supplied permission context.
public static LegacyLoadResult loadFromLegacySessionWithPresence(AgentStateStore stateStore, String userId, String sessionId)
static
加载 `loadFromLegacySessionWithPresence`。
Loads legacy state without discarding the presence of the singleton tool-group key.
public static LegacyLoadResult loadFromLegacySessionWithPresence(AgentStateStore stateStore, String userId, String sessionId, PermissionContextState permCtx)
static
加载 `loadFromLegacySessionWithPresence`。
Loads legacy state without discarding the presence of the singleton tool-group key, and applies the supplied permission context to the reconstructed state.

方法详情Method Detail

loadFromLegacySession

public static AgentState loadFromLegacySession(AgentStateStore stateStore, String userId, String sessionId)
static

加载 loadFromLegacySession。

Load an AgentState from a v1 session.

参数Parameters
名称Name类型Type说明Description
stateStoreAgentStateStore状态存储到读取来自。the state store to read from
userIdString用户标识(类型 `String`)。nullable user identifier
sessionIdString会话标识(类型 `String`)。the session identifier (required)
返回Returns AgentState
返回AgentState。a new AgentState populated with the legacy data
源码Source io/agentscope/core/state/LegacyStateLoader.java:55–58

loadFromLegacySession

public static AgentState loadFromLegacySession(AgentStateStore stateStore, String userId, String sessionId, PermissionContextState permCtx)
static

加载 loadFromLegacySession。

Load an AgentState from a v1 session, applying the supplied permission context.

参数Parameters
名称Name类型Type说明Description
stateStoreAgentStateStore状态存储到读取来自。the state store to read from
userIdString用户标识(类型 `String`)。nullable user identifier
sessionIdString会话标识(类型 `String`)。the session identifier (required)
permCtxPermissionContextStateperm Ctx(类型 `PermissionContextState`)。the permission context to attach, or `null` to keep the default
返回Returns AgentState
返回AgentState。a new AgentState populated with the legacy data
源码Source io/agentscope/core/state/LegacyStateLoader.java:74–80

loadFromLegacySessionWithPresence

public static LegacyLoadResult loadFromLegacySessionWithPresence(AgentStateStore stateStore, String userId, String sessionId)
static

加载 loadFromLegacySessionWithPresence。

Loads legacy state without discarding the presence of the singleton tool-group key.

参数Parameters
名称Name类型Type说明Description
stateStoreAgentStateStore状态存储(类型 `AgentStateStore`)。The state store.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns LegacyLoadResult
返回LegacyLoadResult。Returns legacy load result.
源码Source io/agentscope/core/state/LegacyStateLoader.java:94–97

loadFromLegacySessionWithPresence

public static LegacyLoadResult loadFromLegacySessionWithPresence(AgentStateStore stateStore, String userId, String sessionId, PermissionContextState permCtx)
static

加载 loadFromLegacySessionWithPresence。

Loads legacy state without discarding the presence of the singleton tool-group key, and applies the supplied permission context to the reconstructed state.

参数Parameters
名称Name类型Type说明Description
stateStoreAgentStateStore状态存储到读取来自。the state store to read from
userIdString用户标识(类型 `String`)。nullable user identifier
sessionIdString会话标识(类型 `String`)。the session identifier (required)
permCtxPermissionContextStateperm Ctx(类型 `PermissionContextState`)。the permission context to attach, or `null` to keep the default
返回Returns LegacyLoadResult
返回LegacyLoadResult。the reconstructed legacy state and whether the legacy keys were present
源码Source io/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.

基于官方固定版本源码静态生成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.