Class SandboxManager

java.lang.Object
io.agentscope.harness.agent.sandbox.SandboxManager

public class SandboxManager extends Object
Manages the lifecycle of Sandbox instances for the current call.

Acquire priority: SandboxContext.getExternalSandbox() > SandboxContext.getExternalSandboxState() > persisted SandboxState > SandboxClient.create(io.agentscope.harness.agent.sandbox.WorkspaceSpec, io.agentscope.harness.agent.sandbox.snapshot.SandboxSnapshotSpec, O). When a persisted state exists but the resume fails, the fresh-create fallback keeps the persisted snapshot id so the workspace restores from the previous archive instead of silently resetting.

When a SandboxExecutionGuard is configured, the manager acquires an execution SandboxLease before sandbox resume/create for isolation keys that are present. The lease is carried by the SandboxAcquireResult and closed by the caller (SandboxLifecycleMiddleware) after release(io.agentscope.harness.agent.sandbox.SandboxAcquireResult), ensuring the full call window is covered.

Priority 1 (external sandbox) and Priority 2 (external sandbox state) bypass the guard, since the caller is managing that sandbox externally.