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

sandbox-exec-fallback

Skill này làm gì

Skill này bảo AI agent chuyển từ sandbox mã sang một file Python đã lưu, chạy trong shell. Nó dành cho những người tạo bảng tính, kết quả dữ liệu hoặc các file khác bằng Python.

Khi nào nên dùng

  • ✓Khi sandbox mã lỗi trong lúc tạo bảng tính hoặc file CSV.
  • ✓Khi một công việc xử lý dữ liệu thất bại trong sandbox và bạn vẫn cần kết quả.
  • ✓Khi một công việc Python dài hoặc tốn bộ nhớ cần nhiều thời gian hơn giới hạn của sandbox.

Liên kết skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-exec-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-exec-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

“Sandbox bị lỗi khi tạo bảng chi tiêu của tôi. Hãy lưu mã Python thành file, chạy nó và xác nhận bảng tính đã tồn tại.”

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

Cách hoạt động

Agent ghi toàn bộ mã Python vào một file script, chạy nó bằng python3 trong shell với giới hạn thời gian và kiểm tra đầu ra được in ra. Sau đó nó liệt kê thư mục để tìm các file mà script đã tạo.

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

Use this skill when execute_code_sandbox fails during Python code execution, particularly for tasks involving:

  • Spreadsheet generation (xlsx, csv)
  • Data processing and transformations
  • File output operations
  • Complex computations requiring libraries

Recovery Pattern

When execute_code_sandbox returns an error or fails to produce expected output:

Step 1: Write Python Code to File

Use write_file to save your Python script to a file:

# Use write_file tool with:
path: "script.py"
content: <your complete Python code as a string>

Step 2: Execute via Shell

Use run_shell to execute the script:

# Use run_shell tool with:
command: "python3 script.py"
timeout: <appropriate timeout, e.g., 300 for long-running tasks>

Step 3: Verify Output

Check the shell output for:

  • Success messages or printed results
  • Error messages (if any, diagnose and fix the script)
  • File creation confirmations

Step 4: Access Generated Files

If the script creates output files (e.g., spreadsheets), they will be in the current working directory. Use list_dir to confirm, then read_file to access if needed.

Why This Works

  • Same Python Environment: python3 in the shell uses the same environment as the sandbox
  • More Robust: Shell execution handles long-running or memory-intensive tasks better
  • Debuggable: Errors are captured in stdout/stderr for easier diagnosis
  • Identical Results: Produces the same output as sandbox execution when successful

Example: Spreadsheet Generation

Original code that failed in execute_code_sandbox:

import pandas as pd

data = {'A': [1, 2, 3], 'B': [4, 5, 6]}
df = pd.DataFrame(data)
df.to_excel('output.xlsx', index=False)
print("File created successfully")

Recovery Execution:

  1. write_file with path="generate_spreadsheet.py" and the code above as content
  2. run_shell with command="python3 generate_spreadsheet.py"
  3. Verify output.xlsx was created with list_dir

Tips

  • Increase timeout for complex operations (default 30s may be insufficient)
  • Add explicit print statements for debugging
  • Handle exceptions in your script and print error messages
  • Clean up temporary script files after successful execution if needed
Câu hỏi thường gặp

File đầu ra được lưu ở đâu?

Skill nói các file đầu ra xuất hiện trong thư mục làm việc hiện tại, nên agent liệt kê thư mục đó để tìm chúng.

Script có thể chạy bao lâu?

Skill gợi ý thời gian chờ dài hơn, chẳng hạn 300 giây, cho các công việc dài.

Nếu script vẫn lỗi thì sao?

Skill yêu cầu đọc thông báo lỗi, sửa script và chạy lại.

Chi tiết

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

Fallback pattern for executing Python code when execute_code_sandbox fails by writing to file and running via shell

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12983
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ự