AgentBay AIO Skill
Trigger Conditions: When to Use This Skill
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
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:
-
Check/Create Virtual Environment:
bash
# 检查是否存在 .venv,不存在则创建
if [ ! -d ".venv" ]; then python3 -m venv .venv; fi
-
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/
-
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 (Guide Only When Errors Occur)
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:
- Apply for an API Key at AgentBay Console.
- 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
- Example (macOS/Linux):
mkdir -p ~/.config/agentbay
, then write the key into ~/.config/agentbay/api_key
. For Windows: Create a file named without extension under .
- Inform the user to retry after completion, do not just repeat the error message.
Usage Scenarios
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
to create an AgentBay sandbox, execute code via
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
Use AgentBay SDK to create a session with the
image, execute code in the sandbox via
, parse
EnhancedCodeExecutionResult
, and destroy the session.
Execution Method (Must-Read for Agents)
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
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
- Success: Script exit code 0, result in stdout (or output JSON with : , , , ).
- 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
- Supported : , , , (case-insensitive).
- Single execution timeout is 60 seconds (can be specified with , not exceeding 60).