sandbox-fallback-execution-048d5a
它能做什么
这项技能告诉 AI 智能体,在反复出现沙箱错误后,改为在沙箱之外运行 Python。它适用于不需要沙箱隔离的代码。
适用场景
- ✓当代码沙箱在多次尝试后仍因 e2b 相关错误而失败的时候。
- ✓当代码本身无需沙箱隔离也能安全运行的时候。
- ✓当你需要用 Python 制作电子表格,而沙箱仍然不可用的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-execution-048d5a/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“沙箱已经因 e2b 错误失败了三次。请直接在 shell 中运行我的 Excel 脚本。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把 Python 代码写入工作文件夹中的文件,并通过 shell 用 python3 运行,同时设置时间限制。然后它会读取输出,检查是否有错误或文件生成的信息。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Sandbox Fallback Execution
When execute_code_sandbox repeatedly fails with e2b sandbox errors, use this fallback pattern to execute Python code directly on the host system.
When to Use
Use this skill when:
execute_code_sandboxfails with e2b-related errors- Multiple retry attempts (3+) have not resolved the issue
- The code does not require sandbox isolation
Steps
Step 1: Write Python Script to File
Use write_file to save your Python code as a .py file:
Tool: write_file
path: /workspace/script_name.py
content: |
# Your Python code here
import pandas as pd
# ... rest of code
Step 2: Execute via Shell
Use run_shell with explicit python3 path:
Tool: run_shell
command: python3 /workspace/script_name.py
timeout: 120
Step 3: Verify Output
Check the stdout/stderr from run_shell for:
- Successful execution messages
- Expected output or file creation confirmations
- Any errors that need debugging
Complete Example
# Instead of this (failing):
Tool: execute_code_sandbox
code: |
import pandas as pd
df = pd.DataFrame({'a': [1,2,3]})
df.to_excel('output.xlsx')
# Use this fallback:
Tool: write_file
path: /workspace/generate_report.py
content: |
import pandas as pd
# Create sample data
df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
# Save to Excel
df.to_excel('/workspace/output.xlsx', index=False)
print('File created successfully')
Tool: run_shell
command: python3 /workspace/generate_report.py
timeout: 120
Tips
- Use absolute paths in your Python script when reading/writing files
- Add print statements for debugging since you won't get interactive output
- Increase timeout if the script performs heavy computation
- Check working directory - scripts run from the workspace root by default
- Handle errors explicitly with try/except blocks and meaningful error messages
Common e2b Errors That Trigger This Fallback
E2B execution errorSandbox timeoutConnection refusedSandbox initialization failed- Repeated retry failures (3+ attempts)
When NOT to Use This Fallback
- When sandbox isolation is required for security
- When the code needs specific sandbox environment variables
- On first failure only - try
execute_code_sandboxretry first
常见问题
这里的 e2b 指什么?
它是沙箱服务的名称,这项技能把它的错误作为切换的触发条件。
在沙箱之外运行代码安全吗?
这项技能指出,这种方式仅适用于不需要隔离的代码,因此只应用于你信任的代码。
脚本应保存在哪里?
这项技能使用工作文件夹和完整路径,使输出文件存放在已知的位置。
详情
作者的原始描述
Fallback method to execute Python code when execute_code_sandbox fails with e2b errors
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12988
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。