AS AgentScopeAPI 手册 / API Reference

JpaAgentStateStore

@Transactional public class JpaAgentStateStore implements AgentStateStore
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:45–207

JPA 智能体状态存储,负责持久化与读取数据。位于 io.agentscope.builder.web.persistence.jpa 包,实现 AgentStateStore。核心成员包括 save、getVersioned、get、getList、exists、delete。

Database-backed AgentStateStore for agentscope-builder.

Uses the same Spring DataSource / JPA schema as the rest of the builder catalog (H2 file by default, MySQL/PostgreSQL via the jdbc profile), so short-term brain state is shared across replicas without Redis.

Registered as a Spring bean via DataPlaneConfig#agentStateStore on the data plane; this class itself is not a @Component so tests can supply an alternate AgentStateStore.

构造器摘要Constructor Summary

构造器Constructor说明Description
public JpaAgentStateStore(AgentStateEntityRepository repository, DeletedSessionRegistry deletedSessions)
初始化 `JpaAgentStateStore` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void save(String userId, String sessionId, String key, State value)
保存数据到持久化存储。
Performs the save operation.
public void save(String userId, String sessionId, String key, List<? extends State> values)
保存数据到持久化存储。
Performs the save operation.
public T extends State VersionedState<T> getVersioned(String userId, String sessionId, String key, Class<T> type)
获取 `getVersioned`。
Overridden only so that a transaction is open while the row is read.
public T extends State Optional<T> get(String userId, String sessionId, String key, Class<T> type)
按条件读取数据。
Performs the get operation.
public T extends State List<T> getList(String userId, String sessionId, String key, Class<T> itemType)
获取列表。
Returns the list.
public boolean exists(String userId, String sessionId)
判断数据是否存在。
Performs the exists operation.
public void delete(String userId, String sessionId)
删除数据。
Performs the delete operation.
public void delete(String userId, String sessionId, String key)
删除数据。
Performs the delete operation.
public Set<String> listSessionIds(String userId)
列出 `listSessionIds`。
Lists the session ids.

构造器详情Constructor Detail

JpaAgentStateStore

public JpaAgentStateStore(AgentStateEntityRepository repository, DeletedSessionRegistry deletedSessions)

初始化 JpaAgentStateStore 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
repositoryAgentStateEntityRepository仓库(类型 `AgentStateEntityRepository`)。The repository.
deletedSessionsDeletedSessionRegistry已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:55–65

方法详情Method Detail

save

public void save(String userId, String sessionId, String key, State value)

保存数据到持久化存储。

Performs the save operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
valueState值(类型 `State`)。The value.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:67–75

save

public void save(String userId, String sessionId, String key, List<? extends State> values)

保存数据到持久化存储。

Performs the save operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
valuesList<? extends State>值(类型 `List`)。The values.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:77–85

getVersioned

public T extends State VersionedState<T> getVersioned(String userId, String sessionId, String key, Class<T> type)

获取 getVersioned。

Overridden only so that a transaction is open while the row is read.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
typeClass<T>类型(类型 `Class`)。The type.
返回Returns VersionedState<T>
返回VersionedState。Returns versioned state.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:96–101

get

public T extends State Optional<T> get(String userId, String sessionId, String key, Class<T> type)

按条件读取数据。

Performs the get operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
typeClass<T>类型(类型 `Class`)。The type.
返回Returns Optional<T>
返回可选。Returns optional.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:103–120

getList

public T extends State List<T> getList(String userId, String sessionId, String key, Class<T> itemType)

获取列表。

Returns the list.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
itemTypeClass<T>条目类型(类型 `Class`)。The item type.
返回Returns List<T>
返回列出。Returns list.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:122–141

exists

public boolean exists(String userId, String sessionId)

判断数据是否存在。

Performs the exists operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:143–150

delete

public void delete(String userId, String sessionId)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:152–158

delete

public void delete(String userId, String sessionId, String key)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
keyString键(类型 `String`)。The key.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:160–164

listSessionIds

public Set<String> listSessionIds(String userId)

列出 listSessionIds。

Lists the session ids.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:166–171

继承成员Inherited Members

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