agentbay-aio-skills

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AgentBay AIO 技能

AgentBay AIO Skill

触发条件:何时使用本技能

Trigger Conditions: When to Use This Skill

当用户意图运行或执行代码时即应使用本技能,即使用户没有说「沙箱」。典型表述(遇到即触发):
  • 英文:run this code、execute this script、run the code、execute the script、plot with Python、draw a graph、evaluate this snippet、what's the output of this code、can you run this
  • 中文:帮我跑一下这段代码、运行这段代码、执行这个脚本、用 Python 画个图、跑一下、看下运行结果、执行一下、帮我运行
This skill should be used when the user intends to run or execute code, even if the user does not mention "sandbox". Typical expressions (trigger immediately when encountered):
  • English: run this code, execute this script, run the code, execute the script, plot with Python, draw a graph, evaluate this snippet, what's the output of this code, can you run this
  • Translated User Requests: Help me run this code, run this code, execute this script, plot with Python, run it, check the running result, execute it, help me run it

依赖与环境

Dependencies and Environment

本技能依赖 wuying-agentbay-sdk 包。
最佳实践(Agent 必读):
为避免污染用户当前项目的环境,请务必使用技能目录下的独立虚拟环境
  1. 检查/创建虚拟环境
    bash
    # 检查是否存在 .venv,不存在则创建
    if [ ! -d ".venv" ]; then python3 -m venv .venv; fi
  2. 激活并安装依赖(仅首次或缺失时安装,使用阿里云镜像):
    bash
    source .venv/bin/activate
    pip show wuying-agentbay-sdk >/dev/null 2>&1 || pip install wuying-agentbay-sdk -i https://mirrors.aliyun.com/pypi/simple/
  3. 运行脚本(在虚拟环境中):
    bash
    # 确保在 venv 下运行
    python scripts/run_code.py --code "..." --language python
(若用户明确要求在全局环境运行,或当前已在特定环境中,可跳过创建 venv,但仍建议使用镜像源安装。)
This skill depends on the wuying-agentbay-sdk package.
Best Practices (Must-Read for Agents):
To avoid polluting the user's current project environment, be sure to use the independent virtual environment under the skill directory:
  1. Check/Create Virtual Environment:
    bash
    # 检查是否存在 .venv,不存在则创建
    if [ ! -d ".venv" ]; then python3 -m venv .venv; fi
  2. Activate and Install Dependencies (Install only for the first time or when missing, use Alibaba Cloud mirror):
    bash
    source .venv/bin/activate
    pip show wuying-agentbay-sdk >/dev/null 2>&1 || pip install wuying-agentbay-sdk -i https://mirrors.aliyun.com/pypi/simple/
  3. Run Script (in virtual environment):
    bash
    # 确保在 venv 下运行
    python scripts/run_code.py --code "..." --language python
(If the user explicitly requires running in the global environment, or is already in a specific environment, you can skip creating the venv, but it is still recommended to use the mirror source for installation.)

API Key(仅报错时引导)

API Key (Guide Only When Errors Occur)

默认先直接执行脚本,不要每次运行前都提醒用户配置 API Key。 仅当脚本报错「Missing API key」或类似信息时,再引导用户配置:
  1. AgentBay 控制台 申请 API Key。
  2. 在本地创建配置文件(脚本会从该路径读取):
    • macOS / Linux
      ~/.config/agentbay/api_key
      (或
      $XDG_CONFIG_HOME/agentbay/api_key
    • Windows
      %APPDATA%\agentbay\api_key
  3. 示例(macOS/Linux):
    mkdir -p ~/.config/agentbay
    ,再将密钥写入
    ~/.config/agentbay/api_key
    。Windows:在
    %APPDATA%\agentbay
    下创建名为
    api_key
    的无扩展名文件。
  4. 告知用户完成后重试,不要只复述报错。
By default, execute the script directly; do not remind the user to configure the API Key every time before running. Only when the script reports an error like "Missing API key" or similar, guide the user to configure it:
  1. Apply for an API Key at AgentBay Console.
  2. Create a configuration file locally (the script will read from this path):
    • macOS / Linux:
      ~/.config/agentbay/api_key
      (or
      $XDG_CONFIG_HOME/agentbay/api_key
      )
    • Windows:
      %APPDATA%\agentbay\api_key
  3. Example (macOS/Linux):
    mkdir -p ~/.config/agentbay
    , then write the key into
    ~/.config/agentbay/api_key
    . For Windows: Create a file named
    api_key
    without extension under
    %APPDATA%\agentbay
    .
  4. Inform the user to retry after completion, do not just repeat the error message.

使用场景

Usage Scenarios

所有代码执行类请求均默认使用本技能。 只要用户要求运行代码、执行脚本、评估片段或查看代码输出(Python、JavaScript、R 或 Java),即使用本技能——即使用户未提「沙箱」。使用
code_latest
创建 AgentBay 沙箱,通过
run_code
执行代码并返回结果。在本技能可用时,不要在本地终端执行用户代码;应使用沙箱以保证隔离与行为一致。
All code execution requests use this skill by default. As long as the user requests to run code, execute scripts, evaluate snippets or check code output (Python, JavaScript, R or Java), use this skill — even if the user does not mention "sandbox". Use
code_latest
to create an AgentBay sandbox, execute code via
run_code
and return results. When this skill is available, do not execute user code in the local terminal; use the sandbox to ensure isolation and consistent behavior.

概述

Overview

使用 AgentBay SDK 以
code_latest
镜像创建会话,在沙箱中通过
run_code
执行代码,解析
EnhancedCodeExecutionResult
,并销毁会话。
Use AgentBay SDK to create a session with the
code_latest
image, execute code in the sandbox via
run_code
, parse
EnhancedCodeExecutionResult
, and destroy the session.

执行方式(Agent 必读)

Execution Method (Must-Read for Agents)

请通过本技能自带的脚本执行用户代码 在技能目录下执行:
bash
python scripts/run_code.py --code "用户要执行的代码" --language python
从文件执行:
bash
python scripts/run_code.py --code-file /path/to/file.py --language python
需要结构化输出时加
--json
。脚本会从配置文件或环境变量读取 API Key,创建沙箱、执行并返回结果。
(若用户在自己的 Python 项目中集成 AgentBay,可参考 wuying-agentbay-sdk 的同步/异步用法;Agent 执行本技能时仅需调用上述脚本。)
Please execute user code via the script provided with this skill in the skill directory:
bash
python scripts/run_code.py --code "user's code to execute" --language python
Execute from a file:
bash
python scripts/run_code.py --code-file /path/to/file.py --language python
Add
--json
when structured output is needed. The script will read the API Key from the configuration file or environment variables, create a sandbox, execute and return results.
(If the user integrates AgentBay in their own Python project, refer to the synchronous/asynchronous usage of wuying-agentbay-sdk; Agents only need to call the above scripts when executing this skill.)

脚本输出

Script Output

  • 成功:脚本 exit code 0,结果在 stdout(或加
    --json
    时输出 JSON:
    success
    result
    logs
    error_message
    )。
  • 失败:exit code 非 0,错误信息在 stderr;根据输出提示用户(如缺 API Key 则按「API Key(仅报错时引导)」处理)。
  • Success: Script exit code 0, result in stdout (or output JSON with
    --json
    :
    success
    ,
    result
    ,
    logs
    ,
    error_message
    ).
  • Failure: Non-zero exit code, error message in stderr; prompt the user based on the output (e.g., if missing API Key, follow the "API Key (Guide Only When Errors Occur)" section to handle).

重要约束

Important Constraints

  • language
    支持:
    python
    javascript
    r
    java
    (不区分大小写)。
  • 单次执行超时 60 秒(可用
    --timeout-s
    指定,不超过 60)。
  • Supported
    language
    :
    python
    ,
    javascript
    ,
    r
    ,
    java
    (case-insensitive).
  • Single execution timeout is 60 seconds (can be specified with
    --timeout-s
    , not exceeding 60).