Agent Sandbox Registry

模板

qwen-code

Qwen Code Agent runtime — Dashscope-powered AI autonomous deployment agent

能力 shell files code ports · 状态 official

abx template install alibaba-agent-sandbox/awesome-templates//qwen-code

在每个 provider 上

alicloud-express可安装构建 · 怎么做
alicloud-container已有模板 id 才能创建 · 怎么做
cubesandbox已有模板 id 才能创建 · 怎么做
e2b已有模板 id 才能创建 · 怎么做
opensandbox需要先推送镜像 · 怎么做

说明

qwen-code

中文版 | English


English

Sandbox runtime for the Qwen coding agent — supports qwen-code-driven autonomous deployment and provides a Python 3.12 + Node.js 22 AI coding foundation.

Environment

This template comes preinstalled with the following tools and dependencies:

Category Details
Base image python:3.12-slim
Python Python 3.12 + venv (at /opt/venv)
Node.js Node.js 22.x + npm
Python packages dashscope, openai>=1.0, httpx, rich
Node.js packages @qwen-code/qwen-code@0.23.0
System tools git, curl, wget, ripgrep, jq, build-essential
Resources 2 CPU / 4096 MB memory

Installation

Install from a local path:

abx template install ./qwen-code --registry-type local

Install from GitHub:

abx template install alibaba-agent-sandbox/awesome-templates//qwen-code

Usage

Create a sandbox instance and pass in the API key:

abx create --template qwen-code --env DASHSCOPE_API_KEY=sk-xxx

Call a Qwen model inside the sandbox via the DashScope SDK:

abx exec <sandbox-id> -- python3 -c "
import dashscope
from dashscope import Generation
response = Generation.call(model='qwen-turbo', prompt='Write a quicksort algorithm')
print(response.output.text)
"

The OpenAI-compatible interface is also supported:

abx exec <sandbox-id> -- python3 -c "
from openai import OpenAI
client = OpenAI(
    api_key='your-dashscope-key',
    base_url='https://dashscope.aliyuncs.com/compatible-mode/v1'
)
response = client.chat.completions.create(
    model='qwen-turbo',
    messages=[{'role': 'user', 'content': 'Write a quicksort'}]
)
print(response.choices[0].message.content)
"

Using the Python SDK:

from agent_sandbox import Sandbox

sandbox = Sandbox.create_sync(
    template="qwen-code",
    env={"DASHSCOPE_API_KEY": "sk-xxx"}
)

result = sandbox.commands.run("python3 --version && node --version")
print(result.stdout)

Configuration

Environment Variables

Variable Description Required
DASHSCOPE_API_KEY Alibaba Cloud DashScope API key Yes
WORKSPACE Working directory path, defaults to /workspace No

Manual AI Coding Tool Installation

This template already ships with the qwen-code CLI, ready to use:

# Use qwen-code for NL-based deployment
abx run <sandbox-id> qwen --prompt "Deploy this FastAPI project"

# Or use the qwen command directly inside the sandbox
abx exec <sandbox-id> -- qwen -p "Analyze the project and deploy it" --yolo

To install additional tools:

# Install extra Python packages
abx exec <sandbox-id> -- pip install <agent-package>

# Install extra Node.js tools
abx exec <sandbox-id> -- npm install -g <agent-tool>

Notes


中文

通义千问(Qwen)编码 Agent 的沙箱运行环境,支持 qwen-code 驱动的 AI 自主部署,提供 Python 3.12 + Node.js 22 的 AI 编程基础环境。

环境说明

本模板预装以下工具和依赖:

类别 内容
基础镜像 python:3.12-slim
Python Python 3.12 + venv 虚拟环境(位于 /opt/venv)
Node.js Node.js 22.x + npm
Python 包 dashscope、openai>=1.0、httpx、rich
Node.js 包 @qwen-code/qwen-code@0.23.0
系统工具 git、curl、wget、ripgrep、jq、build-essential
资源配置 2 CPU / 4096 MB 内存

安装方式

从本地安装:

abx template install ./qwen-code --registry-type local

从 GitHub 安装:

abx template install alibaba-agent-sandbox/awesome-templates//qwen-code

使用示例

创建沙箱实例并传入 API Key:

abx create --template qwen-code --env DASHSCOPE_API_KEY=sk-xxx

在沙箱中通过 DashScope SDK 调用 Qwen 模型:

abx exec <sandbox-id> -- python3 -c "
import dashscope
from dashscope import Generation
response = Generation.call(model='qwen-turbo', prompt='编写一个快速排序算法')
print(response.output.text)
"

也支持使用 OpenAI 兼容接口:

abx exec <sandbox-id> -- python3 -c "
from openai import OpenAI
client = OpenAI(
    api_key='your-dashscope-key',
    base_url='https://dashscope.aliyuncs.com/compatible-mode/v1'
)
response = client.chat.completions.create(
    model='qwen-turbo',
    messages=[{'role': 'user', 'content': '编写一个快速排序'}]
)
print(response.choices[0].message.content)
"

使用 Python SDK:

from agent_sandbox import Sandbox

sandbox = Sandbox.create_sync(
    template="qwen-code",
    env={"DASHSCOPE_API_KEY": "sk-xxx"}
)

result = sandbox.commands.run("python3 --version && node --version")
print(result.stdout)

配置说明

环境变量

变量名 说明 必填
DASHSCOPE_API_KEY 阿里云 DashScope API 密钥 是
WORKSPACE 工作目录路径,默认 /workspace 否

手动安装 AI 编码工具

本模板已预装 qwen-code CLI 工具,可直接使用:

# 使用 qwen-code 进行 NL 部署
abx run <sandbox-id> qwen --prompt "部署这个 FastAPI 项目"

# 或在沙箱内直接使用 qwen 命令
abx exec <sandbox-id> -- qwen -p "分析项目并部署" --yolo

如需安装额外工具:

# 安装额外 Python 包
abx exec <sandbox-id> -- pip install <agent-package>

# 安装额外 Node.js 工具
abx exec <sandbox-id> -- npm install -g <agent-tool>

注意事项

Deploy and local e2e

Install and register this template:

abx template install alibaba-agent-sandbox/awesome-templates//qwen-code

From this directory (build, push, and register):

abx deploy

From the repository root, with agent-sandbox-server and httpx installed:

python3 scripts/run_local_e2e.py

That starts python3 commands.py in this directory and runs e2e_test.py.

文件