AgentRunSandbox
public class AgentRunSandbox extends AbstractBaseSandbox
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:39–268智能体运行沙箱,在隔离环境中安全执行代码和工具。位于 io.agentscope.extensions.sandbox.agentrun 包,继承自 AbstractBaseSandbox。核心成员包括 start、stop、shutdown、probeWorkspaceRootForPreservedResume、doExec、doPersistWorkspace。
io.agentscope.harness.agent.sandbox.Sandbox backed by an Alibaba Cloud AgentRun sandbox
(FC 3.0 Sandbox API 2025-09-10).
Execution runs over the AgentRun MCP server bundled with the sandbox template. When the
sandbox state declares workspaceOnNas=true, persistence is delegated entirely to the
NAS mount and #doPersistWorkspace() is a no-op; otherwise the sandbox falls back to a
tar-via-MCP archive identical in shape to Daytona's payload.
构造器摘要Constructor Summary
方法摘要Method Summary
构造器详情Constructor Detail
AgentRunSandbox
public AgentRunSandbox(AgentRunSandboxState state, AgentRunSandboxClientOptions options, AgentRunDataPlaneHttp http, AgentRunMcpChannel mcp)
初始化 AgentRunSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | AgentRunSandboxState | 状态对象(类型 `AgentRunSandboxState`)。The state. |
options | AgentRunSandboxClientOptions | 选项(类型 `AgentRunSandboxClientOptions`)。The options. |
http | AgentRunDataPlaneHttp | HTTP(类型 `AgentRunDataPlaneHttp`)。The http. |
mcp | AgentRunMcpChannel | MCP(类型 `AgentRunMcpChannel`)。The mcp. |
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:53–63方法详情Method Detail
start
public void start() throws Exception
执行启动相关操作。
Returns the start.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:65–75stop
public void stop() throws Exception
执行停止相关操作。
Returns the stop.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:77–87shutdown
public void shutdown() throws Exception
关闭资源并释放连接。
Releases resources and connections.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:89–105probeWorkspaceRootForPreservedResume
protected boolean probeWorkspaceRootForPreservedResume()
返回 probeWorkspaceRootForPreservedResume 结果。
Returns the probe workspace root for preserved resume.
booleanio/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:107–115doExec
protected ExecResult doExec(RuntimeContext runtimeContext, String command, int timeoutSeconds) throws Exception
执行 doExec 回调。
Performs the do exec operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
command | String | 命令(类型 `String`)。The command. |
timeoutSeconds | int | 超时秒(类型 `int`)。The timeout seconds. |
ExecResultException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:117–132doPersistWorkspace
protected InputStream doPersistWorkspace() throws Exception
执行 doPersistWorkspace 回调。
Returns the do persist workspace.
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:134–151doHydrateWorkspace
protected void doHydrateWorkspace(InputStream archive) throws Exception
执行 doHydrateWorkspace 回调。
Performs the do hydrate workspace operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
archive | InputStream | 归档(类型 `InputStream`)。The archive. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:153–188doSetupWorkspace
protected void doSetupWorkspace() throws Exception
执行 doSetupWorkspace 回调。
Returns the do setup workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:190–193doDestroyWorkspace
protected void doDestroyWorkspace() throws Exception
执行 doDestroyWorkspace 回调。
Returns the do destroy workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:195–206getWorkspaceRoot
protected String getWorkspaceRoot()
获取工作区根。
Returns the workspace root.
Stringio/agentscope/extensions/sandbox/agentrun/AgentRunSandbox.java:208–211