AS AgentScopeAPI 手册 / API Reference

MongoDistributedStore

public class MongoDistributedStore implements DistributedStore, AutoCloseable
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:71–322

Mongo 分布式存储,负责持久化与读取数据。位于 io.agentscope.extensions.mongodb 包,实现 DistributedStore、AutoCloseable。核心成员包括 create、fromConnectionString、agentStateStore、baseStore、sandboxSnapshotSpec、sandboxExecutionGuard。

MongoDB-backed DistributedStore.

Usage:

`MongoClient mongoClient = MongoClients.create("mongodb://localhost:27017");

HarnessAgent agent = HarnessAgent.builder()
.name("my-agent")
.model("dashscope:qwen-plus")
.distributedStore(MongoDistributedStore.create(mongoClient, "agentscope"))
.build();
`

This configures:

  • MongoAgentStateStore — agent session state in MongoDB

  • MongoBaseStore — workspace filesystem KV in MongoDB

  • MongoSandboxExecutionGuard — sandbox execution locking in MongoDB

  • MongoSnapshotSpec — sandbox workspace snapshots in MongoDB

When created via #create(MongoClient), the caller owns the MongoClient lifecycle; #close() will NOT close the client. When created via #fromConnectionString(String), the store owns the client and #close() will close it. In both cases, #close() also cascades to shut down any cached MongoSandboxExecutionGuard executor.

方法摘要Method Summary

方法Method说明Description
public static MongoDistributedStore create(MongoClient mongoClient)
static
创建MongoDB 分布式存储使用默认数据库名称(`"agentscope"`)。
Creates a MongoDB distributed store with the default database name (`"agentscope"`).
public static MongoDistributedStore create(MongoClient mongoClient, String databaseName)
static
创建MongoDB 分布式存储。
Creates a MongoDB distributed store.
public static MongoDistributedStore fromConnectionString(String connectionString)
static
设置该参数。
Creates a MongoDB distributed store from a connection string.
public AgentStateStore agentStateStore()
返回智能体状态存储。
Returns the agent state store.
public BaseStore baseStore()
返回基类存储。
Returns the base store.
public SandboxSnapshotSpec sandboxSnapshotSpec()
返回沙箱快照规格。
Returns the sandbox snapshot spec.
public SandboxExecutionGuard sandboxExecutionGuard()
返回沙箱执行守卫。
Returns the sandbox execution guard.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.

方法详情Method Detail

create

public static MongoDistributedStore create(MongoClient mongoClient)
static

创建MongoDB 分布式存储使用默认数据库名称("agentscope")。

Creates a MongoDB distributed store with the default database name ("agentscope").

参数Parameters
名称Name类型Type说明Description
mongoClientMongoClientMongoDB 客户端。the MongoDB client
返回Returns MongoDistributedStore
一种新的MongoDB 分布式存储。a new MongoDB distributed store
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:101–103

create

public static MongoDistributedStore create(MongoClient mongoClient, String databaseName)
static

创建MongoDB 分布式存储。

Creates a MongoDB distributed store.

参数Parameters
名称Name类型Type说明Description
mongoClientMongoClientMongoDB 客户端。the MongoDB client
databaseNameString数据库名称。the database name
返回Returns MongoDistributedStore
一种新的MongoDB 分布式存储。a new MongoDB distributed store
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:112–114

fromConnectionString

public static MongoDistributedStore fromConnectionString(String connectionString)
static

设置该参数。

Creates a MongoDB distributed store from a connection string.

参数Parameters
名称Name类型Type说明Description
connectionStringString连接 String(类型 `String`)。the MongoDB connection string
返回Returns MongoDistributedStore
一种新的MongoDB 分布式存储。a new MongoDB distributed store
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:126–131

agentStateStore

public AgentStateStore agentStateStore()

返回智能体状态存储。

Returns the agent state store.

返回Returns AgentStateStore
返回AgentStateStore。Returns agent state store.
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:133–152

baseStore

public BaseStore baseStore()

返回基类存储。

Returns the base store.

返回Returns BaseStore
返回BaseStore。Returns base store.
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:259–273

sandboxSnapshotSpec

public SandboxSnapshotSpec sandboxSnapshotSpec()

返回沙箱快照规格。

Returns the sandbox snapshot spec.

返回Returns SandboxSnapshotSpec
返回SandboxSnapshotSpec。Returns sandbox snapshot spec.
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:275–288

sandboxExecutionGuard

public SandboxExecutionGuard sandboxExecutionGuard()

返回沙箱执行守卫。

Returns the sandbox execution guard.

返回Returns SandboxExecutionGuard
返回SandboxExecutionGuard。Returns sandbox execution guard.
源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:290–307

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/extensions/mongodb/MongoDistributedStore.java:309–321

继承成员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.