Class MongoDistributedStore

java.lang.Object
io.agentscope.extensions.mongodb.MongoDistributedStore
All Implemented Interfaces:
io.agentscope.harness.agent.DistributedStore, AutoCloseable

public class MongoDistributedStore extends Object implements io.agentscope.harness.agent.DistributedStore, AutoCloseable
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:

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.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.agentscope.harness.agent.DistributedStore

    io.agentscope.harness.agent.DistributedStore.Builder, io.agentscope.harness.agent.DistributedStore.CompositeDistributedStore
  • Method Summary

    Modifier and Type
    Method
    Description
    io.agentscope.core.state.AgentStateStore
     
    io.agentscope.harness.agent.filesystem.remote.store.BaseStore
     
    void
     
    create(com.mongodb.client.MongoClient mongoClient)
    Creates a MongoDB distributed store with the default database name ("agentscope").
    create(com.mongodb.client.MongoClient mongoClient, String databaseName)
    Creates a MongoDB distributed store.
    fromConnectionString(String connectionString)
    Creates a MongoDB distributed store from a connection string.
    io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
     
    io.agentscope.harness.agent.sandbox.snapshot.SandboxSnapshotSpec
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.agentscope.harness.agent.DistributedStore

    asyncToolRegistry, messageBus, sessionTurnGate, taskRepository, teamClient
  • Method Details

    • create

      public static MongoDistributedStore create(com.mongodb.client.MongoClient mongoClient)
      Creates a MongoDB distributed store with the default database name ("agentscope").
      Parameters:
      mongoClient - the MongoDB client
      Returns:
      a new MongoDB distributed store
    • create

      public static MongoDistributedStore create(com.mongodb.client.MongoClient mongoClient, String databaseName)
      Creates a MongoDB distributed store.
      Parameters:
      mongoClient - the MongoDB client
      databaseName - the database name
      Returns:
      a new MongoDB distributed store
    • fromConnectionString

      public static MongoDistributedStore fromConnectionString(String connectionString)
      Creates a MongoDB distributed store from a connection string. A new MongoClient is created internally and owned by the store; close() will close it.

      If the connection string includes a database path (e.g. "mongodb://host:27017/mydb"), that database is used instead of the default.

      Parameters:
      connectionString - the MongoDB connection string
      Returns:
      a new MongoDB distributed store
    • agentStateStore

      public io.agentscope.core.state.AgentStateStore agentStateStore()
      Specified by:
      agentStateStore in interface io.agentscope.harness.agent.DistributedStore
    • baseStore

      public io.agentscope.harness.agent.filesystem.remote.store.BaseStore baseStore()
      Specified by:
      baseStore in interface io.agentscope.harness.agent.DistributedStore
    • sandboxSnapshotSpec

      public io.agentscope.harness.agent.sandbox.snapshot.SandboxSnapshotSpec sandboxSnapshotSpec()
      Specified by:
      sandboxSnapshotSpec in interface io.agentscope.harness.agent.DistributedStore
    • sandboxExecutionGuard

      public io.agentscope.harness.agent.sandbox.SandboxExecutionGuard sandboxExecutionGuard()
      Specified by:
      sandboxExecutionGuard in interface io.agentscope.harness.agent.DistributedStore
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable