Conversation
Signed-off-by: Sodawyx <sodawyx@126.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
There was a problem hiding this comment.
Pull request overview
This PR extends the Sandbox SDK APIs to support user-specified sandbox IDs during creation, fixes Config passthrough so request-level headers/tokens reach the Data API, and adjusts connect/connect_async to skip get_template when template_type is provided (avoiding AKSK-required control-plane calls). It also adds spec-driven OpenSpec documentation for these changes.
Changes:
- Add optional
sandbox_idtoSandbox.create/create_async→SandboxClient.create_sandbox(_async)→SandboxDataAPI.create_sandbox(_async)and serialize it assandboxIdin the create request body. - Fix
configpassthrough forget/stop/deletecalls down toDataAPIHTTP methods, and changeconnect/connect_asyncto avoidget_templatewhentemplate_typeis provided. - Add OpenSpec config and archived specs/tasks/design/proposals documenting the above behaviors.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
openspec/config.yaml |
Adds OpenSpec rules/config for spec-driven workflow. |
openspec/changes/archive/2026-03-05-remove-get-template-from-connect/* |
Spec/proposal/design/tasks documenting connect skipping get_template when template_type is provided. |
openspec/changes/archive/2026-03-05-fix-sandbox-config-passthrough/* |
Spec/proposal/design/tasks documenting Config passthrough fixes. |
openspec/changes/archive/2026-03-05-add-create-sandbox-id/* |
Spec/proposal/design/tasks documenting optional sandboxId support on create. |
agentrun/sandbox/sandbox.py |
Adds sandbox_id to create overloads and changes connect logic to use provided template_type without calling get_template. |
agentrun/sandbox/__sandbox_async_template.py |
Template source for generated sandbox.py; adds sandbox_id plumbing and connect_async behavior change. |
agentrun/sandbox/client.py |
Adds sandbox_id to create methods; fixes config passthrough for get/stop/delete (sync+async). |
agentrun/sandbox/__client_async_template.py |
Template source for generated client.py; updates create signature and config passthrough calls. |
agentrun/sandbox/api/sandbox_data.py |
Adds sandbox_id serialization to create request body; forwards config into HTTP calls. |
agentrun/sandbox/api/__sandbox_data_async_template.py |
Template source for generated sandbox_data.py; adds sandboxId and config passthrough. |
Comments suppressed due to low confidence (4)
agentrun/sandbox/sandbox.py:335
Sandbox.create()accepts aconfigparameter but doesn't pass it intoSandboxClient.create_sandbox(...), so per-call config (headers/token/timeouts) is ignored during sandbox creation. Please forwardconfigto the client call (and keep template + generated file in sync).
# 创建 Sandbox(返回基类实例)
base_sandbox = cls.__get_client().create_sandbox(
template_name=template_name,
sandbox_idle_timeout_seconds=sandbox_idle_timeout_seconds,
sandbox_id=sandbox_id,
nas_config=nas_config,
oss_mount_config=oss_mount_config,
polar_fs_config=polar_fs_config,
)
agentrun/sandbox/__sandbox_async_template.py:327
connect_asyncno longer validates that a providedtemplate_typematches the server-side template type, but theRaises:docstring still claims it will error on mismatch. Please update the docstring to avoid promising a check that no longer exists (and keep generatedsandbox.pyin sync).
"""连接一个SandBox(异步)
Args:
sandbox_id: Sandbox ID
template_type: 可选的类型参数,用于类型提示和运行时类型决定。
提供时直接使用该类型决定返回的子类,不调用 get_template(无需 AKSK)。
未提供时通过 get_template 获取类型(需要 AKSK)。
config: 配置对象
Returns:
Sandbox: 根据模板类型返回对应的 Sandbox 子类对象
Raises:
ValueError: 如果模板类型不支持或与预期类型不匹配
"""
agentrun/sandbox/sandbox.py:260
Sandbox.create_async()passesconfigintoget_template_async, but does not passconfigintoSandboxClient.create_sandbox_async(...), so user-supplied headers/token are ignored for the actual sandbox creation request. Please forwardconfigto the client call (and regenerate if this file is codegen output).
# 创建 Sandbox(返回基类实例)
base_sandbox = await cls.__get_client().create_sandbox_async(
template_name=template_name,
sandbox_idle_timeout_seconds=sandbox_idle_timeout_seconds,
sandbox_id=sandbox_id,
nas_config=nas_config,
oss_mount_config=oss_mount_config,
polar_fs_config=polar_fs_config,
)
agentrun/sandbox/__sandbox_async_template.py:190
- In the template source,
Sandbox.create_async()does not pass theconfigparameter intoSandboxClient.create_sandbox_async(...), so user-supplied config is ignored for the creation request. Please forwardconfigto the client call so codegen output (sandbox.py) preserves per-request config.
base_sandbox = await cls.__get_client().create_sandbox_async(
template_name=template_name,
sandbox_idle_timeout_seconds=sandbox_idle_timeout_seconds,
sandbox_id=sandbox_id,
nas_config=nas_config,
oss_mount_config=oss_mount_config,
polar_fs_config=polar_fs_config,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
agentrun/sandbox/__sandbox_async_template.py:327
connect_async的 docstring 里Raises: ValueError仍描述“与预期类型不匹配”,但当前逻辑在用户传入template_type时已不再做类型校验(直接用传入值决定子类)。建议更新异常说明,避免误导使用者(例如仅说明不支持的类型、缺少 template_name 等场景)。
"""连接一个SandBox(异步)
Args:
sandbox_id: Sandbox ID
template_type: 可选的类型参数,用于类型提示和运行时类型决定。
提供时直接使用该类型决定返回的子类,不调用 get_template(无需 AKSK)。
未提供时通过 get_template 获取类型(需要 AKSK)。
config: 配置对象
Returns:
Sandbox: 根据模板类型返回对应的 Sandbox 子类对象
Raises:
ValueError: 如果模板类型不支持或与预期类型不匹配
"""
agentrun/sandbox/__sandbox_async_template.py:190
Sandbox.create_async接收了config参数并用于get_template_async,但创建沙箱时调用cls.__get_client().create_sandbox_async(...)没有把config透传下去,导致用户传入的 headers/token 等配置不会进入 Data API 请求。建议在调用create_sandbox_async时显式传入config=config,并通过 codegen 同步到生成文件。
base_sandbox = await cls.__get_client().create_sandbox_async(
template_name=template_name,
sandbox_idle_timeout_seconds=sandbox_idle_timeout_seconds,
sandbox_id=sandbox_id,
nas_config=nas_config,
oss_mount_config=oss_mount_config,
polar_fs_config=polar_fs_config,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
openspec/changes/archive/2026-03-05-add-create-sandbox-id/proposal.md
Outdated
Show resolved
Hide resolved
Co-developed-by: Aone Copilot <noreply@alibaba-inc.com> Signed-off-by: Sodawyx <sodawyx@126.com>
57bfc24 to
01faafe
Compare
Fix bugs
Bug detail
Pull request tasks
Update docs
Reason for update
Pull request tasks
Add contributor
Contributed content
Content detail
Others
Reason for update