JpaAgentStateStore
@Transactional public class JpaAgentStateStore implements AgentStateStore
io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:45–207JPA 智能体状态存储,负责持久化与读取数据。位于 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
构造器详情Constructor Detail
JpaAgentStateStore
public JpaAgentStateStore(AgentStateEntityRepository repository, DeletedSessionRegistry deletedSessions)
初始化 JpaAgentStateStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repository | AgentStateEntityRepository | 仓库(类型 `AgentStateEntityRepository`)。The repository. |
deletedSessions | DeletedSessionRegistry | 已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions. |
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
key | String | 键(类型 `String`)。The key. |
value | State | 值(类型 `State`)。The value. |
io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:67–75save
public void save(String userId, String sessionId, String key, List<? extends State> values)
保存数据到持久化存储。
Performs the save operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
key | String | 键(类型 `String`)。The key. |
values | List<? extends State> | 值(类型 `List`)。The values. |
io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:77–85getVersioned
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
key | String | 键(类型 `String`)。The key. |
type | Class<T> | 类型(类型 `Class`)。The type. |
VersionedState<T>io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:96–101get
public T extends State Optional<T> get(String userId, String sessionId, String key, Class<T> type)
按条件读取数据。
Performs the get operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
key | String | 键(类型 `String`)。The key. |
type | Class<T> | 类型(类型 `Class`)。The type. |
Optional<T>io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:103–120getList
public T extends State List<T> getList(String userId, String sessionId, String key, Class<T> itemType)
获取列表。
Returns the list.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
key | String | 键(类型 `String`)。The key. |
itemType | Class<T> | 条目类型(类型 `Class`)。The item type. |
List<T>io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:122–141exists
public boolean exists(String userId, String sessionId)
判断数据是否存在。
Performs the exists operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
booleanio/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:143–150delete
public void delete(String userId, String sessionId)
删除数据。
Performs the delete operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:152–158delete
public void delete(String userId, String sessionId, String key)
删除数据。
Performs the delete operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
key | String | 键(类型 `String`)。The key. |
io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:160–164listSessionIds
public Set<String> listSessionIds(String userId)
列出 listSessionIds。
Lists the session ids.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
Set<String>io/agentscope/builder/web/persistence/jpa/JpaAgentStateStore.java:166–171