AS AgentScopeAPI 手册 / API Reference

SandboxAcquireResult

public final class SandboxAcquireResult
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:35–78

沙箱 Acquire 结果,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.sandbox 包。核心成员包括 selfManaged、userManaged、getSandbox、isSelfManaged、getLease。

Result of acquiring a Sandbox from SandboxManager.

Two ownership modes:

  • self-managed (selfManaged=true): the SDK created the sandbox and is responsible for its full lifecycle — stop() + shutdown() are both called after each agent call.

  • user-managed (selfManaged=false): the caller injected a pre-existing sandbox; the SDK only calls stop() and never calls shutdown().

When a SandboxExecutionGuard is configured, the result also carries the SandboxLease that was acquired before sandbox resume/create. The harness closes it after SandboxManager#release completes to cover the full call window.

方法摘要Method Summary

方法Method说明Description
public static SandboxAcquireResult selfManaged(Sandbox sandbox, SandboxLease lease)
static
执行自身托管相关操作。
Creates a self-managed result with a guard lease (SDK owns the full lifecycle).
public static SandboxAcquireResult selfManaged(Sandbox sandbox)
static
设置自身托管。
Creates a self-managed result with no guard (SDK owns the full lifecycle).
public static SandboxAcquireResult userManaged(Sandbox sandbox)
static
设置用户托管。
Creates a user-managed result (caller owns the lifecycle; SDK only calls stop).
public Sandbox getSandbox()
获取沙箱。
Returns the sandbox.
public boolean isSelfManaged()
判断是否自身托管。
Returns `true` if the SDK owns the full sandbox lifecycle.
public SandboxLease getLease()
获取 `getLease`。
Returns the `SandboxLease` held for this call, or a no-op lease if no guard was configured.

方法详情Method Detail

selfManaged

public static SandboxAcquireResult selfManaged(Sandbox sandbox, SandboxLease lease)
static

执行自身托管相关操作。

Creates a self-managed result with a guard lease (SDK owns the full lifecycle).

参数Parameters
名称Name类型Type说明Description
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
leaseSandboxLeaselease(类型 `SandboxLease`)。The lease.
返回Returns SandboxAcquireResult
返回SandboxAcquireResult。Returns sandbox acquire result.
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:48–50

selfManaged

public static SandboxAcquireResult selfManaged(Sandbox sandbox)
static

设置自身托管。

Creates a self-managed result with no guard (SDK owns the full lifecycle).

参数Parameters
名称Name类型Type说明Description
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
返回Returns SandboxAcquireResult
返回SandboxAcquireResult。Returns sandbox acquire result.
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:53–55

userManaged

public static SandboxAcquireResult userManaged(Sandbox sandbox)
static

设置用户托管。

Creates a user-managed result (caller owns the lifecycle; SDK only calls stop).

参数Parameters
名称Name类型Type说明Description
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
返回Returns SandboxAcquireResult
返回SandboxAcquireResult。Returns sandbox acquire result.
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:58–60

getSandbox

public Sandbox getSandbox()

获取沙箱。

Returns the sandbox.

返回Returns Sandbox
返回沙箱。Returns sandbox.
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:62–64

isSelfManaged

public boolean isSelfManaged()

判断是否自身托管。

Returns true if the SDK owns the full sandbox lifecycle.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:67–69

getLease

public SandboxLease getLease()

获取 getLease。

Returns the SandboxLease held for this call, or a no-op lease if no guard was configured.

返回Returns SandboxLease
返回SandboxLease。Returns sandbox lease.
源码Source io/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:75–77
基于官方固定版本源码静态生成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.