Enum Class IsolationScope

java.lang.Object
java.lang.Enum<IsolationScope>
io.agentscope.harness.agent.IsolationScope
All Implemented Interfaces:
Serializable, Comparable<IsolationScope>, Constable

public enum IsolationScope extends Enum<IsolationScope>
Controls how agent state is isolated and shared across calls.

This enum is the canonical isolation-scope definition used by both the sandbox filesystem backend (SandboxContext) and the remote filesystem backend (RemoteFilesystemSpec).

Sandbox semantics: the scope determines which key is used when persisting and loading _sandbox.json state. Calls that resolve to the same scope key will sequentially reuse the same sandbox (each call resumes the persisted state from the previous one).

Store namespace semantics: the scope determines the namespace prefix used by RemoteFilesystem when routing files to the shared key-value store. Different scopes produce different namespace prefixes, controlling which calls share the same view of stored files.

Scope selection:

  • USER – shared across all sessions of the same user; the default. When userId is absent, falls back to SESSION.
  • SESSION – isolated per session.
  • AGENT – shared across all users and sessions of the same agent.
  • GLOBAL – globally shared within the same workspace/store instance.

Concurrency note: for sandbox mode this is sequential-reuse sharing, not live-instance sharing. Concurrent calls at the same scope each get their own running container; they converge on the last persisted snapshot at the end of the call.

  • Enum Constant Details

    • SESSION

      public static final IsolationScope SESSION
      Isolate by session identifier.

      Each distinct session gets its own sandbox state / store namespace. If no session key is present in the RuntimeContext, state lookup is skipped and a fresh sandbox is created (or a default store namespace is used).

    • USER

      public static final IsolationScope USER
      Share across all sessions belonging to the same userId.

      This is the default scope. If userId is absent, resolution falls back to SESSION using the session identifier instead.

    • AGENT

      public static final IsolationScope AGENT
      Share across all users and sessions of the same agent (identified by agent name).

      The agent name is fixed at build time and is always available; this scope never degrades due to a missing context field.

    • GLOBAL

      public static final IsolationScope GLOBAL
      One shared state / namespace globally within the same workspace store instance.

      Use with care: all agents and users that share the same store will compete to write the global slot.

  • Method Details

    • values

      public static IsolationScope[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static IsolationScope valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toNamespaceFactory

      public NamespaceFactory toNamespaceFactory()
      Creates a NamespaceFactory that derives the filesystem namespace prefix from the RuntimeContext according to this scope.
      • USER — prefix with userId; falls back to sessionId when userId is absent.
      • SESSION — prefix with sessionId.
      • AGENT / GLOBAL — no prefix (workspace is already per-agent).
      Returns:
      a namespace factory consistent with this scope