sandbox-fallback-execution
Skill này làm gì
Skill này cho AI agent một phương án dự phòng đơn giản cho mã Python khi sandbox lỗi hoặc hết giờ. Nó dành cho những người cần hoàn thành một công việc Python ngắn mà không dùng sandbox.
Khi nào nên dùng
- ✓Khi sandbox mã lỗi không rõ nguyên nhân hoặc hết giờ.
- ✓Khi sandbox đã lỗi hơn hai lần cho cùng một công việc.
- ✓Khi một gói Python cần được cài trước khi mã có thể chạy.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-execution/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Sandbox báo lỗi không rõ nguyên nhân với script của tôi. Hãy cài pandas nếu cần và chạy mã qua shell.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent cài mọi gói cần thiết bằng pip, rồi chạy mã Python qua shell bằng heredoc. Nó kiểm tra đầu ra để tìm thông báo thành công hoặc lỗi trước khi đi tiếp.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Sandbox Fallback Execution
When to Use This Skill
Use this pattern when execute_code_sandbox fails with unknown errors, timeouts, or persistent execution failures. This fallback bypasses sandbox restrictions by using run_shell with a Python heredoc script.
Pattern Overview
execute_code_sandbox fails → run_shell with pip install → Python heredoc execution
Step-by-Step Instructions
Step 1: Detect Sandbox Failure
Monitor for these failure indicators from execute_code_sandbox:
- Unknown or unexplained errors
- Repeated execution failures (>2 attempts)
- Timeout errors
- Environment/package availability issues
Step 2: Install Required Dependencies (If Needed)
Use run_shell to install any required Python packages:
pip install <package_name>
For multiple packages:
pip install package1 package2 package3
Step 3: Execute Python via Heredoc
Run Python code using a heredoc script with run_shell:
python3 << 'EOF'
# Your Python code here
import sys
print("Hello from fallback execution")
EOF
Key heredoc syntax notes:
- Use
<< 'EOF'(quoted) to prevent shell variable expansion - Use
<< EOF(unquoted) if you need shell variable interpolation - Close with
EOFon its own line
Step 4: Verify and Iterate
- Check stdout/stderr for success indicators
- If errors persist, inspect output and adjust the script
- Capture any generated artifacts (files, outputs) for verification
Complete Example
Scenario: Need to create a Word document but execute_code_sandbox keeps failing.
# Step 1: Install required package
pip install python-docx
# Step 2: Execute Python script via heredoc
python3 << 'EOF'
from docx import Document
doc = Document()
doc.add_heading('Proposal Document', 0)
doc.add_paragraph('This is the proposal content.')
doc.save('proposal.docx')
print("Document created successfully")
EOF
Best Practices
- Quote the heredoc delimiter (
'EOF') to avoid unintended shell expansion of Python code - Install packages first before running the script to ensure availability
- Print status messages in your script for easier debugging
- Save outputs to files when possible for verification
- Keep scripts focused - break complex tasks into multiple heredoc executions if needed
Troubleshooting
| Issue | Solution |
|---|---|
pip not found |
Try pip3 or python3 -m pip install |
| Script hangs | Add timeout to run_shell command |
| Permission errors | Check file paths are writable |
| Import errors | Verify package was installed successfully |
Related Tools
run_shell: Execute shell commands directlyexecute_code_sandbox: Primary Python execution tool (try first)shell_agent: For more complex multi-step shell tasks
Câu hỏi thường gặp
Khác nhau giữa EOF có dấu nháy và không có dấu nháy là gì?
Dấu kết thúc có nháy ngăn shell thay đổi biến, còn dấu không có nháy cho phép shell điền giá trị vào.
Agent có cài gói không?
Có, nếu mã cần một gói, skill yêu cầu cài bằng pip trước.
Nếu vẫn còn lỗi thì sao?
Skill yêu cầu đọc đầu ra, chỉnh sửa mã và chạy lại.
Chi tiết
Mô tả gốc của tác giả
Fallback workflow for executing Python code when execute_code_sandbox fails
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12990
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.