execute-code-fallback
Fungsinya
Skill ini memberi tahu AI untuk beralih ke menjalankan Python di shell ketika sandbox kode tidak bisa terhubung atau kehabisan waktu. Skill ini cocok untuk orang yang tugas AI-nya membutuhkan kode yang berjalan meskipun layanan sandbox sedang tidak aktif.
Kapan dipakai
- ✓Saat sandbox kode melaporkan bahwa ia tidak tersedia atau tidak bisa dijangkau.
- ✓Saat sandbox kehabisan waktu atau gagal dua kali atau lebih berturut-turut.
- ✓Saat kode membutuhkan paket tambahan yang harus dipasang sebelum dijalankan.
Link skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/execute-code-fallback/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Sandbox kode sedang tidak aktif sekarang. Tolong jalankan skrip Python di shell, dan pasang dulu paket yang dibutuhkannya.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
AI memasang paket yang diperlukan dengan pip, lalu menjalankan kode Python melalui perintah shell, dengan heredoc untuk skrip yang lebih panjang.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Execute Code Fallback Pattern
When execute_code_sandbox fails due to e2b unavailability, immediately fall back to run_shell with embedded Python code. This ensures task continuity when the sandbox service is down.
When to Apply
Use this pattern when you observe:
execute_code_sandboxreturns errors mentioning "e2b", "sandbox unavailable", or connection timeouts- Repeated sandbox execution failures (2+ attempts)
- Error messages indicating the code execution environment is unreachable
Fallback Procedure
Step 1: Detect the Failure
Identify that execute_code_sandbox has failed. Common error indicators:
- "e2b service unavailable"
- "Sandbox connection failed"
- "Execution environment not reachable"
- Timeout errors during code execution
Step 2: Switch to run_shell with Embedded Python
Instead of:
execute_code_sandbox(code="...")
Use:
run_shell(command="python3 -c '...your Python code...'")
Step 3: Install Dependencies First (If Needed)
If your Python code requires external packages, install them first:
run_shell(command="pip install pandas requests matplotlib")
Then execute your main code:
run_shell(command="python3 << 'EOF'
import pandas as pd
import requests
# Your code here
print("Success")
EOF
")
Step 4: Use Heredoc for Multi-line Code
For complex Python scripts, use heredoc syntax for cleaner code:
run_shell(command="python3 << 'PYTHON_SCRIPT'
import json
import os
# Complex logic here
data = {'key': 'value'}
with open('output.json', 'w') as f:
json.dump(data, f)
print('File created successfully')
PYTHON_SCRIPT
")
Complete Example
Scenario: You need to process a CSV file and generate a report.
Original approach (sandbox):
execute_code_sandbox(code="""
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
""")
Fallback approach (run_shell):
# First install dependencies if needed
run_shell(command="pip install pandas --quiet")
# Then execute the code
run_shell(command="python3 << 'EOF'
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
EOF
")
Important Considerations
State Persistence: Unlike
execute_code_sandbox,run_shellexecutions may not share state between calls. Save intermediate results to files if needed.Working Directory: Ensure you're operating in the correct directory. Use
pwdto verify or includecd /path/to/workdirin your commands.Python Version: Use
python3explicitly to avoid ambiguity. Verify withpython3 --versionif needed.Error Handling: Check the stdout/stderr from
run_shellto confirm success. Failed Python scripts will return non-zero exit codes.Security: Be cautious when embedding user-provided data into shell commands. Escape appropriately or use file-based input.
Performance: For large computations,
run_shellmay be slower than sandbox. Consider breaking into smaller steps if timeouts occur.
Quick Reference
| Task | Sandbox Approach | Fallback Approach |
|---|---|---|
| Simple calculation | execute_code_sandbox(code="print(2+2)") |
run_shell(command="python3 -c 'print(2+2)'") |
| Install + run | execute_code_sandbox(code="import pkg; ...") |
run_shell(command="pip install pkg && python3 -c '...'") |
| Multi-line script | execute_code_sandbox(code="...") |
run_shell(command="python3 << 'EOF'...EOF") |
| File I/O | execute_code_sandbox(code="...") |
run_shell(command="python3 << 'EOF'...EOF") |
Recovery Checklist
- Confirm
execute_code_sandboxfailure (not a code bug) - Switch to
run_shellimmediately - Install required packages with
pip install - Use heredoc for multi-line Python
- Verify output and handle errors
- Save intermediate results to files if multi-step
Pertanyaan umum
Galat apa yang memicu peralihan?
Panduan ini mencantumkan pesan bahwa sandbox tidak tersedia, waktu koneksi habis, dan lingkungan eksekusi yang tidak bisa dijangkau.
Bagaimana paket ditambahkan?
Paket dipasang lebih dulu dengan pip sebelum kode utama dijalankan.
Mengapa memakai heredoc?
Heredoc memungkinkan skrip multi-baris dijalankan dengan satu perintah shell.
Detail
Deskripsi asli dari pembuat
Fallback from execute_code_sandbox to run_shell when e2b sandbox is unavailable
repo: HKUDS/AgentPilot
Popularitas
- Bintang GitHub
- 7.8k
- Peringkat
- #12878
- Lisensi
- MIT
- Diperbarui
- 1/11/2026
Komentar
- …
Skill lain dari repositori ini
agentpilot
7.8kMembantu agent Anda meningkatkan proyek langkah demi langkah dengan menyiapkan tugas dan menjalankan loop AgentPilot yang mengusulkan, menguji, dan memberi skor pada perubahan.
openspace
7.8kMembantu agent Anda menyiapkan OpenSpace, alat yang menyimpan dan mengambil skill agent, lalu menghubungkannya ke aplikasi AI Anda melalui MCP.
rsi-arena
7.8kMembantu agent Anda menyiapkan dan menjalankan tes benchmark AI standar, seperti AIME dan Terminal-Bench, untuk membandingkan berbagai metode perbaikan.
experiment-guide
7.8kMembantu agent Anda merencanakan eksperimen kecil, membaca hasilnya, dan mencatat temuan saat menyelidiki cara memperbaiki sebuah program.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.