AS AgentScopeAPI 手册 / API Reference

IsolationScope

public enum IsolationScope
源码Source io/agentscope/harness/agent/IsolationScope.java:53–127

定义隔离范围相关取值的枚举。位于 io.agentscope.harness.agent 包。核心成员包括 toNamespaceFactory、SESSION、USER、AGENT、GLOBAL。

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 (io.agentscope.harness.agent.sandbox.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 Summary

常量Constant说明Description
SESSION
执行会话相关操作。
Isolate by session identifier.
USER
执行用户相关操作。
Share across all sessions belonging to the same userId (`io.agentscope.core.agent.RuntimeContext#getUserId()`).
AGENT
执行智能体相关操作。
Share across all users and sessions of the same agent (identified by agent name).
GLOBAL
执行 `GLOBAL` 方法。
One shared state / namespace globally within the same workspace store instance.

方法摘要Method Summary

方法Method说明Description
public NamespaceFactory toNamespaceFactory()
返回到命名空间工厂。
Creates a `NamespaceFactory` that derives the filesystem namespace prefix from the `io.agentscope.core.agent.RuntimeContext` according to this scope.

枚举常量详情Enum Constant Detail

SESSION

SESSION
staticfinal

执行会话相关操作。

Isolate by session identifier.

源码Source io/agentscope/harness/agent/IsolationScope.java:62

USER

USER
staticfinal

执行用户相关操作。

Share across all sessions belonging to the same userId (io.agentscope.core.agent.RuntimeContext#getUserId()).

源码Source io/agentscope/harness/agent/IsolationScope.java:71

AGENT

AGENT
staticfinal

执行智能体相关操作。

Share across all users and sessions of the same agent (identified by agent name).

源码Source io/agentscope/harness/agent/IsolationScope.java:79

GLOBAL

GLOBAL
staticfinal

执行 GLOBAL 方法。

One shared state / namespace globally within the same workspace store instance.

源码Source io/agentscope/harness/agent/IsolationScope.java:87

方法详情Method Detail

toNamespaceFactory

public NamespaceFactory toNamespaceFactory()

返回到命名空间工厂。

Creates a NamespaceFactory that derives the filesystem namespace prefix from the io.agentscope.core.agent.RuntimeContext according to this scope.

返回Returns NamespaceFactory
返回NamespaceFactory。a namespace factory consistent with this scope
源码Source io/agentscope/harness/agent/IsolationScope.java:102–126
基于官方固定版本源码静态生成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.