Interface DistributedStore

All Known Implementing Classes:
DistributedStore.CompositeDistributedStore

public interface DistributedStore
One-stop configuration for distributed and persistent storage components.

Instead of configuring AgentStateStore, BaseStore, SandboxSnapshotSpec, and SandboxExecutionGuard individually, pass a single DistributedStore to HarnessAgent.Builder.distributedStore(DistributedStore):


 // Single store — all components from Redis
 DistributedStore store = RedisDistributedStore.fromJedis(jedis);

 // Mixed stores — MySQL for state/files, Redis for sandbox lock/snapshot
 DistributedStore store = DistributedStore.builder()
     .agentStateStore(mysqlStore.agentStateStore())
     .baseStore(mysqlStore.baseStore())
     .sandboxSnapshotSpec(redisStore.sandboxSnapshotSpec())
     .sandboxExecutionGuard(redisStore.sandboxExecutionGuard())
     .build();

 HarnessAgent.builder()
     .distributedStore(store)
     .filesystem(new RemoteFilesystemSpec()
             .isolationScope(IsolationScope.USER))
     .build();
 

distributedStore auto-wires AgentStateStore and sandbox components (snapshot, execution guard). The workspace filesystem mode (RemoteFilesystemSpec, DockerFilesystemSpec, etc.) is always configured explicitly by the user via .filesystem(...).

Implementations are provided by extension modules:

  • agentscope-extensions-cos — CosDistributedStore
  • agentscope-extensions-jdbc — JdbcDistributedStore
  • agentscope-extensions-mongodb — MongoDistributedStore
  • agentscope-extensions-oss — OssDistributedStore
  • agentscope-extensions-redis — RedisDistributedStore

Priority: explicit builder methods (.stateStore(), .filesystem()) take precedence over distributedStore for the components they configure.

  • Method Details

    • agentStateStore

      io.agentscope.core.state.AgentStateStore agentStateStore()
      Creates the AgentStateStore for agent session state persistence.
      Returns:
      a distributed agent state store; must not be null
    • baseStore

      BaseStore baseStore()
      Creates the BaseStore for workspace filesystem KV storage.
      Returns:
      a distributed base store; must not be null
    • sandboxSnapshotSpec

      default SandboxSnapshotSpec sandboxSnapshotSpec()
      Creates the SandboxSnapshotSpec for sandbox snapshot persistence.

      Override this when the store supports binary blob storage suitable for Docker sandbox snapshots. The default returns NoopSnapshotSpec (no snapshots).

      Returns:
      a sandbox snapshot spec; must not be null
    • sandboxExecutionGuard

      default SandboxExecutionGuard sandboxExecutionGuard()
      Creates the SandboxExecutionGuard for distributed sandbox concurrency control.

      Override this when the store supports distributed locking. The default returns a no-op guard (no cross-node coordination).

      Returns:
      a sandbox execution guard; must not be null
    • messageBus

      default MessageBus messageBus()
      Creates a MessageBus for inbox-based message delivery and session event streaming.

      Override this when the store supports real-time transport (e.g. Redis Pub/Sub). The default returns null, which signals HarnessAgent to fall back to a workspace-backed implementation created from the resolved AbstractFilesystem.

      Returns:
      a message bus, or null to use the workspace default
    • asyncToolRegistry

      default AsyncToolRegistry asyncToolRegistry()
      Creates an AsyncToolRegistry for tracking async tool executions.

      Override this when the store supports persistent key-value storage. The default returns null, which signals HarnessAgent to fall back to a workspace-backed implementation.

      Returns:
      an async tool registry, or null to use the workspace default
    • taskRepository

      default TaskRepository taskRepository()
      Creates a TaskRepository for distributed subagent background tasks.

      Override this when the store supports hosted task persistence (e.g. control-plane /api/v1/dp/tasks/*). The default returns null, which signals HarnessAgent to fall back to a workspace-backed WorkspaceTaskRepository.

      Returns:
      a task repository, or null to use the workspace default
    • sessionTurnGate

      default SessionTurnGate sessionTurnGate()
      Creates a SessionTurnGate for distributed per-session turn serialization.

      Override this when the store supports hosted locks (e.g. control-plane /api/v1/dp/locks/*). The default returns null, which signals HarnessAgent to use the gateway's built-in LocalSessionTurnGate.

      When a distributed turn gate is used, configure ReActAgent conflictPolicy to FAIL so concurrent state writes surface as errors rather than silent overwrites.

      Returns:
      a session turn gate, or null to use the process-local default
    • teamClient

      default TeamClient teamClient()
      Creates a TeamClient for AgentTeams coordination.

      Override when the store hosts team task/message APIs (control plane) or can back a local CAS client. The default returns null.

      Returns:
      a team client, or null when teams mode is unavailable
    • builder

      static DistributedStore.Builder builder()
      Creates a builder for composing a DistributedStore from individual components, potentially sourced from different store implementations.

      Example — MySQL for state and files, Redis for sandbox:

      
       DistributedStore mysql = MysqlDistributedStore.create(dataSource);
       DistributedStore redis = RedisDistributedStore.fromJedis(jedis);
      
       DistributedStore mixed = DistributedStore.builder()
           .agentStateStore(mysql.agentStateStore())
           .baseStore(mysql.baseStore())
           .sandboxSnapshotSpec(redis.sandboxSnapshotSpec())
           .sandboxExecutionGuard(redis.sandboxExecutionGuard())
           .build();
       
      Returns:
      a new builder