Chuyển đến nội dung
Skillpedia
Lập trình chung7.8k · #12986

sandbox-execution-fallback

Skill này làm gì

Skill này chỉ cho AI agent cách khôi phục một lần chạy mã thất bại bằng cách lưu mã vào file .py và chạy trong shell. Nó dành cho những người có công việc bảng tính hoặc dữ liệu bị hết giờ trong sandbox.

Khi nào nên dùng

  • ✓Khi sandbox mã hết giờ với một công việc bảng tính hoặc dữ liệu.
  • ✓Khi một công việc cần thư viện bên ngoài như pandas hoặc openpyxl.
  • ✓Khi một phép tính dài liên tục chạm giới hạn thời gian của sandbox.

Liên kết skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-execution-fallback/SKILL.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-execution-fallback/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Công việc pandas của tôi bị hết giờ trong sandbox. Hãy lưu mã vào file và chạy nó trong shell với giới hạn dài hơn.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent lấy mã đã lỗi, ghi nó vào một file .py với tên rõ ràng, chạy bằng Python hệ thống và kiểm tra các file cùng kết quả mong đợi có ở đó.

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

When to Use

Apply this pattern when execute_code_sandbox fails or times out, particularly for:

  • Spreadsheet generation (pandas, openpyxl, xlsxwriter)
  • Complex data processing with file I/O
  • Tasks requiring external library imports
  • Long-running computations that hit timeout limits

Recovery Procedure

Step 1: Capture the Python Code

Extract or reconstruct the Python code that failed in execute_code_sandbox.

Step 2: Write Code to File

Use write_file to save the script with a .py extension:

write_file(
    path="script_name.py",
    content="""
import pandas as pd
# Your implementation here
"""
)

Step 3: Execute via run_shell

Run the script using the system Python interpreter:

run_shell(command="python3 script_name.py")

Step 4: Verify Output

Confirm the results match expected outputs (files created, data processed correctly, etc.).

Complete Example

# Failed: execute_code_sandbox with pandas Excel generation

# Recovery - Step 1 & 2: Write script to file
write_file(
    path="generate_pnl_report.py",
    content="""
import pandas as pd
from openpyxl import Workbook

# Create sample data
data = {
    'Category': ['Revenue', 'Expenses', 'Tax'],
    'Amount': [10000, 3000, 500]
}
df = pd.DataFrame(data)

# Write to Excel
df.to_excel('pnl_report.xlsx', index=False)
print('Report generated: pnl_report.xlsx')
"""
)

# Step 3: Execute via shell
run_shell(command="python3 generate_pnl_report.py")

# Step 4: Verify file was created
run_shell(command="ls -la pnl_report.xlsx")

Why This Works

Aspect execute_code_sandbox run_shell + write_file
Environment Sandboxed, limited Full system Python
File I/O Restricted Full access
Timeout Strict limits More flexible
Library Support May be limited System-installed packages
Result Identical output Identical output

Best Practices

  1. Use descriptive filenames - e.g., generate_report.py, process_data.py
  2. Add error handling - Include try/except blocks in your script
  3. Print progress - Use print statements for debugging
  4. Clean up - Remove temporary scripts after successful execution if needed
  5. Verify results - Always confirm outputs before proceeding

Common Use Cases

  • Excel/CSV report generation
  • Data transformation pipelines
  • Batch file processing
  • API data aggregation
  • Chart and visualization creation

Troubleshooting

If run_shell also fails:

  1. Check Python is available: run_shell(command="python3 --version")
  2. Install missing packages: run_shell(command="pip3 install pandas openpyxl")
  3. Check file permissions and paths
  4. Review stderr output for specific errors
Câu hỏi thường gặp

Agent có khôi phục được mã nếu nó đã mất không?

Skill yêu cầu dựng lại mã từ lần thử thất bại nếu nó chưa được lưu.

Lệnh Python nào được dùng?

Skill chạy script bằng python3 từ shell.

Agent kiểm tra thành công bằng cách nào?

Nó xác nhận các file đã được tạo và dữ liệu đã được xử lý đúng như mong đợi.

Chi tiết

Mô tả gốc của tác giả

Recover from execute_code_sandbox failures by writing Python scripts to files and executing via run_shell

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12986
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự