OssAgentStateStore
public class OssAgentStateStore implements AgentStateStore
io/agentscope/extensions/oss/OssAgentStateStore.java:66–349OSS 智能体状态存储,负责持久化与读取数据。位于 io.agentscope.extensions.oss 包,实现 AgentStateStore。核心成员包括 builder、save、get、getList、exists、delete。
Alibaba Cloud OSS backed AgentStateStore.
State objects are stored as JSON files in an OSS bucket with the following key layout:
{keyPrefix}{userId}/{sessionId}/{stateKey}.json — single State value
{keyPrefix}{userId}/{sessionId}/{stateKey}.list.json — List<State> as JSON array
{keyPrefix}{userId}/{sessionId}/{stateKey}.list.hash — hash for incremental append detection
Usage:
`OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
AgentStateStore store = OssAgentStateStore.builder()
.ossClient(ossClient)
.bucketName("my-agentscope-bucket")
.keyPrefix("agentscope/state/")
.build();
HarnessAgent agent = HarnessAgent.builder()
.stateStore(store)
.build();
`
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.extensions.oss that connects agents to messaging channels and enterprise platforms. |
方法摘要Method Summary
方法详情Method Detail
builder
public static Builder builder()
返回构建器实例。
Returns the builder.
Builderio/agentscope/extensions/oss/OssAgentStateStore.java:87–89save
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/extensions/oss/OssAgentStateStore.java:91–100save
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/extensions/oss/OssAgentStateStore.java:102–132get
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/extensions/oss/OssAgentStateStore.java:134–147getList
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/extensions/oss/OssAgentStateStore.java:149–168exists
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/extensions/oss/OssAgentStateStore.java:170–182delete
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/extensions/oss/OssAgentStateStore.java:184–195delete
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/extensions/oss/OssAgentStateStore.java:197–215listSessionIds
public Set<String> listSessionIds(String userId)
列出 listSessionIds。
Lists the session ids.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
Set<String>io/agentscope/extensions/oss/OssAgentStateStore.java:217–234close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/extensions/oss/OssAgentStateStore.java:236–239嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.oss 包。核心成员包括 ossClient、bucketName、keyPrefix、build。
A class in io.agentscope.extensions.oss that connects agents to messaging channels and enterprise platforms. Declared in io.agentscope.extensions.oss.