sandbox-fallback-python
Skill này làm gì
Skill này hướng dẫn AI agent chạy Python bằng shell khi không kết nối được với sandbox. Nó dành cho những người có tác vụ Python phụ thuộc vào gói và xuất file.
Khi nào nên dùng
- ✓Khi sandbox báo rằng nó không khả dụng hoặc kết nối thất bại.
- ✓Khi một script Python cần các gói phải được cài trước.
- ✓Khi một script cần đọc hoặc ghi file trong thư mục làm việc.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python/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 không khả dụng. Hãy cài các gói script của tôi cần, rồi chạy nó và lưu đầu ra vào thư mục làm việc của tôi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent cài các gói bằng pip, rồi chạy mã Python qua shell bằng heredoc. Nó dùng đường dẫn rõ ràng cho file và liệt kê thư mục để xác nhận đầu ra đã được lưu.
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: Python via run_shell
When to Use This Skill
Apply this skill when execute_code_sandbox fails with errors indicating:
- e2b service unavailability
- Sandbox timeout or connection issues
- Code execution environment not accessible
This fallback allows you to execute Python code directly via shell, bypassing the sandbox infrastructure.
Fallback Procedure
Step 1: Detect Sandbox Failure
Identify fallback necessity from error messages like:
- "e2b unavailable"
- "sandbox connection failed"
- "execution environment error"
- Timeout errors during code execution
Step 2: Switch to run_shell with Embedded Python
Instead of execute_code_sandbox, use run_shell with a Python heredoc or inline script:
python3 << 'EOF'
# Your Python code here
print("Hello from fallback execution")
EOF
Step 3: Install Dependencies First
If your Python code requires packages not guaranteed to be installed:
pip install package_name package_name2 && python3 << 'EOF'
# Your Python code here
import package_name
print("Code with dependencies executed")
EOF
Step 4: Handle File I/O
For scripts that need to read/write files:
- Use absolute or explicit relative paths
- Files persist in the workspace directory
- List directory contents with
lsto verify file operations
python3 << 'EOF'
import os
# Write output to file
with open("output.txt", "w") as f:
f.write("Results here")
# Verify
print(f"Working directory: {os.getcwd()}")
EOF
Code Examples
Simple Calculation
python3 << 'EOF'
result = sum(range(100))
print(f"Sum: {result}")
EOF
With Package Installation
pip install requests -q && python3 << 'EOF'
import requests
response = requests.get("https://api.example.com/data")
print(response.json())
EOF
With JSON Processing
python3 << 'EOF'
import json
data = {"key": "value", "count": 42}
output = json.dumps(data, indent=2)
print(output)
# Save to file
with open("data.json", "w") as f:
f.write(output)
EOF
Best Practices
- Use heredoc syntax -
<< 'EOF'prevents variable expansion issues - Install quietly - Use
pip install -qto reduce output noise - Error handling - Add try/except blocks in Python code for robustness
- Verify execution - Check stdout/stderr from run_shell to confirm success
- Keep code compact - Long scripts are harder to debug in shell context
Caveats
- No persistent state between run_shell calls (unlike execute_code_sandbox)
- Longer execution time for complex scripts due to Python interpreter startup
- Limited debugging - Cannot easily inspect variables between statements
- Output size limits - Very large outputs may be truncated
When NOT to Use This Fallback
- If the task specifically requires sandbox isolation for security
- If you need persistent state across multiple code executions
- If the code execution is extremely long-running (consider backgrounding)
Câu hỏi thường gặp
Agent kiểm tra đầu ra bằng cách nào?
Nó đọc các thông báo từ shell và liệt kê thư mục để xem các file mới.
Tại sao dùng đường dẫn rõ ràng?
Đường dẫn rõ ràng đảm bảo file được lưu đúng trong thư mục làm việc bạn mong đợi.
Có chạy được mà không cài gì không?
Nếu các gói đã có sẵn, có thể bỏ qua bước cài đặt.
Chi tiết
Mô tả gốc của tác giả
Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12992
- 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á.