AS AgentScopeAPI 手册 / API Reference

ExternalSandboxRegistry

@Component public class ExternalSandboxRegistry
源码Source io/agentscope/builder/web/managed/ExternalSandboxRegistry.java:32–56

外部沙箱注册表,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.managed 包。核心成员包括 register、get、remove、size。

Live sessionId -> Sandbox handles registered by an Environment Worker (a remote worker calling the worker REST API).

HandsLeaseService polls this registry after enqueueing a work item on EnvironmentWorkQueue; once a worker registers a sandbox for the session, the harness attaches it to the turn's io.agentscope.harness.agent.sandbox.SandboxContext as the Priority-1 externalSandbox, so the harness never starts, stops, or shuts it down — the worker owns the full lifecycle.

方法摘要Method Summary

方法Method说明Description
public void register(String sessionId, Sandbox sandbox)
执行注册相关操作。
Registers (or replaces) the live sandbox for a session.
public Sandbox get(String sessionId)
按条件读取数据。
Returns the live sandbox for a session, or `null` if none is registered.
public Sandbox remove(String sessionId)
设置移除。
Removes and returns the live sandbox for a session, or `null` if none was registered.
public int size()
返回大小。
Returns the number of currently registered sandboxes.

方法详情Method Detail

register

public void register(String sessionId, Sandbox sandbox)

执行注册相关操作。

Registers (or replaces) the live sandbox for a session.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
源码Source io/agentscope/builder/web/managed/ExternalSandboxRegistry.java:38–40

get

public Sandbox get(String sessionId)

按条件读取数据。

Returns the live sandbox for a session, or null if none is registered.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Sandbox
返回沙箱。Returns sandbox.
源码Source io/agentscope/builder/web/managed/ExternalSandboxRegistry.java:43–45

remove

public Sandbox remove(String sessionId)

设置移除。

Removes and returns the live sandbox for a session, or null if none was registered.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Sandbox
返回沙箱。Returns sandbox.
源码Source io/agentscope/builder/web/managed/ExternalSandboxRegistry.java:48–50

size

public int size()

返回大小。

Returns the number of currently registered sandboxes.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/builder/web/managed/ExternalSandboxRegistry.java:53–55
基于官方固定版本源码静态生成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.