sandbox-execution-fallback-238489
Skill này làm gì
Skill này hướng dẫn AI agent tạo một script Python độc lập và chạy nó khi sandbox không xử lý được một công việc dựa trên thư viện. Nó dành cho những người cần PDF, file Word hoặc bảng tính.
Khi nào nên dùng
- ✓Khi sandbox lỗi khi tạo file PDF, Word hoặc Excel.
- ✓Khi công việc cần một thư viện Python mà sandbox không cung cấp.
- ✓Khi bạn cần kiểm soát nhiều hơn môi trường mà script chạy trong đó.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-execution-fallback-238489/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
“Tạo một PDF từ ghi chú của tôi bằng reportlab. Sandbox bị lỗi, nên hãy viết file script và chạy nó.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent dùng công cụ ghi file để lưu script, rồi chạy nó bằng python3 qua shell. Sau đó nó kiểm tra script đã chạy xong và đã tạo đúng các file mong đợi.
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 Execution Fallback
This skill provides a reliable fallback pattern when execute_code_sandbox fails for code execution tasks (especially PDF generation, complex file operations, or library-dependent tasks).
When to Use
Use this fallback pattern when:
execute_code_sandboxreturns errors or fails to produce expected output- The task requires specific Python libraries not available in the sandbox
- File I/O operations (especially PDF, docx, xlsx) fail in the sandbox environment
- You need more control over the execution environment
Step-by-Step Instructions
Step 1: Write the Python Script to a File
Instead of executing code directly in the sandbox, use write_file to create a standalone Python script:
Use write_file to create a script (e.g., script.py) with your complete Python code.
Step 2: Execute the Script Directly
Run the script using run_shell with Python:
Use run_shell with command: python3 script.py
Step 3: Verify Output
Check that the script executed successfully and produced the expected files or output.
Example Pattern
Instead of this (sandbox execution):
execute_code_sandbox with code using libraries like reportlab, fpdf, etc.
Do this (fallback pattern):
# Step 1: Create the script
write_file:
path: generate_pdf.py
content: |
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
def create_pdf(filename):
c = canvas.Canvas(filename, pagesize=letter)
c.drawString(100, 750, "Hello World")
c.save()
create_pdf("output.pdf")
# Step 2: Execute directly
run_shell:
command: python3 generate_pdf.py
Best Practices
- Include all dependencies in the script - Make the script self-contained
- Add error handling - Include try/except blocks to catch and report errors
- Use absolute or clear relative paths - Ensure file paths work in the execution context
- Verify prerequisites - Check that required Python packages are available
- Clean up temporary files - Remove intermediate scripts after successful execution if needed
Troubleshooting
If run_shell also fails:
- Check if Python 3 is available:
run_shell command: python3 --version - Install missing packages:
run_shell command: pip3 install package_name - Check file permissions and paths
- Review error output from the shell execution for specific issues
Why This Works
This pattern bypasses sandbox limitations by:
- Running code in the actual execution environment with full library access
- Avoiding sandbox timeout or resource constraints
- Enabling direct file system access for I/O operations
- Providing better error messages from the native Python interpreter
Self-Assessment
This skill captures a genuinely reusable pattern that:
- Is generalizable beyond just PDF generation to any execute_code_sandbox failure
- Provides clear, actionable steps
- Includes example code and troubleshooting guidance
- Would benefit future executions facing similar sandbox limitations
Câu hỏi thường gặp
Skill này áp dụng cho những loại file nào?
Skill nêu PDF, Word và Excel là các loại đầu ra thường lỗi trong sandbox.
Tại sao ghi thành file thay vì chạy mã trực tiếp?
Một script đã lưu cho shell một file rõ ràng để chạy và giúp công việc dễ kiểm tra hơn.
Agent có xác nhận đầu ra không?
Có, bước cuối là kiểm tra xem các file mong đợi đã được tạo chưa.
Chi tiết
Mô tả gốc của tác giả
Fallback pattern for when execute_code_sandbox fails - write script to file and execute directly with run_shell
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12984
- 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á.