SandboxAcquireResult
public final class SandboxAcquireResult
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 callsstop()and never callsshutdown().
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)
执行自身托管相关操作。
Creates a self-managed result with a guard lease (SDK owns the full lifecycle).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandbox | Sandbox | 沙箱(类型 `Sandbox`)。The sandbox. |
lease | SandboxLease | lease(类型 `SandboxLease`)。The lease. |
SandboxAcquireResultio/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:48–50selfManaged
public static SandboxAcquireResult selfManaged(Sandbox sandbox)
设置自身托管。
Creates a self-managed result with no guard (SDK owns the full lifecycle).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandbox | Sandbox | 沙箱(类型 `Sandbox`)。The sandbox. |
SandboxAcquireResultio/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:53–55userManaged
public static SandboxAcquireResult userManaged(Sandbox sandbox)
设置用户托管。
Creates a user-managed result (caller owns the lifecycle; SDK only calls stop).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandbox | Sandbox | 沙箱(类型 `Sandbox`)。The sandbox. |
SandboxAcquireResultio/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:58–60getSandbox
public Sandbox getSandbox()
获取沙箱。
Returns the sandbox.
Sandboxio/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:62–64isSelfManaged
public boolean isSelfManaged()
判断是否自身托管。
Returns true if the SDK owns the full sandbox lifecycle.
booleanio/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:67–69getLease
public SandboxLease getLease()
获取 getLease。
Returns the SandboxLease held for this call, or a no-op lease if no guard was configured.
SandboxLeaseio/agentscope/harness/agent/sandbox/SandboxAcquireResult.java:75–77