execute-code-fallback
What it does
This skill tells the AI to switch to running Python in the shell when the code sandbox cannot connect or times out. It is for people whose AI tasks need code to run even when the sandbox service is down.
When to use it
- ✓When the code sandbox reports that it is unavailable or cannot be reached.
- ✓When the sandbox has timed out or failed two or more times in a row.
- ✓When the code needs extra packages that must be installed before it runs.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/execute-code-fallback/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“The code sandbox is down right now. Please run the Python script in the shell, installing any packages it needs first.”
5 new skills a week. 1 minute to read.
How it works
The AI installs any required packages with pip, then runs the Python code through a shell command, using a heredoc for longer scripts.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
What errors trigger the switch?
The guide mentions messages about the sandbox being unavailable, connection timeouts and unreachable execution environments.
How are packages added?
The guide installs them first with pip, before running the main code.
Why use a heredoc?
It lets a multi-line script run from a single shell command.
Details
Original description by the author
Fallback from execute_code_sandbox to run_shell when e2b sandbox is unavailable
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12878
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.