Package io.agentscope.extensions.oss
Class OssAgentStateStore
java.lang.Object
io.agentscope.extensions.oss.OssAgentStateStore
- All Implemented Interfaces:
io.agentscope.core.state.AgentStateStore
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
Nested Classes -
Field Summary
Fields inherited from interface io.agentscope.core.state.AgentStateStore
UNVERSIONED -
Method Summary
Modifier and TypeMethodDescriptionstatic OssAgentStateStore.Builderbuilder()voidclose()voidvoidboolean<T extends io.agentscope.core.state.State>
Optional<T><T extends io.agentscope.core.state.State>
List<T>listSessionIds(String userId) voidvoidsave(String userId, String sessionId, String key, List<? extends io.agentscope.core.state.State> values) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.state.AgentStateStore
getVersioned, saveIfVersion, supportsVersioning
-
Method Details
-
builder
-
save
- Specified by:
savein interfaceio.agentscope.core.state.AgentStateStore
-
save
public void save(String userId, String sessionId, String key, List<? extends io.agentscope.core.state.State> values) - Specified by:
savein interfaceio.agentscope.core.state.AgentStateStore
-
get
public <T extends io.agentscope.core.state.State> Optional<T> get(String userId, String sessionId, String key, Class<T> type) - Specified by:
getin interfaceio.agentscope.core.state.AgentStateStore
-
getList
public <T extends io.agentscope.core.state.State> List<T> getList(String userId, String sessionId, String key, Class<T> itemType) - Specified by:
getListin interfaceio.agentscope.core.state.AgentStateStore
-
exists
- Specified by:
existsin interfaceio.agentscope.core.state.AgentStateStore
-
delete
- Specified by:
deletein interfaceio.agentscope.core.state.AgentStateStore
-
delete
- Specified by:
deletein interfaceio.agentscope.core.state.AgentStateStore
-
listSessionIds
- Specified by:
listSessionIdsin interfaceio.agentscope.core.state.AgentStateStore
-
close
public void close()- Specified by:
closein interfaceio.agentscope.core.state.AgentStateStore
-