sandbox-fallback-python
What it does
This skill guides the AI agent to run Python with the shell when the sandbox cannot be reached. It is for people whose Python tasks depend on packages and file output.
When to use it
- ✓When the sandbox reports that it is unavailable or the connection failed.
- ✓When a Python script needs packages that must be installed first.
- ✓When a script must read or write files in the workspace folder.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python/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 sandbox is unavailable. Install the packages my script needs, then run it and save the output in my workspace.”
5 new skills a week. 1 minute to read.
How it works
The agent installs the packages with pip, then runs the Python code through the shell with a heredoc. It uses explicit paths for files and lists the folder to confirm that the output was saved.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Sandbox Fallback: Python via run_shell
When to Use This Skill
Apply this skill when execute_code_sandbox fails with errors indicating:
- e2b service unavailability
- Sandbox timeout or connection issues
- Code execution environment not accessible
This fallback allows you to execute Python code directly via shell, bypassing the sandbox infrastructure.
Fallback Procedure
Step 1: Detect Sandbox Failure
Identify fallback necessity from error messages like:
- "e2b unavailable"
- "sandbox connection failed"
- "execution environment error"
- Timeout errors during code execution
Step 2: Switch to run_shell with Embedded Python
Instead of execute_code_sandbox, use run_shell with a Python heredoc or inline script:
python3 << 'EOF'
# Your Python code here
print("Hello from fallback execution")
EOF
Step 3: Install Dependencies First
If your Python code requires packages not guaranteed to be installed:
pip install package_name package_name2 && python3 << 'EOF'
# Your Python code here
import package_name
print("Code with dependencies executed")
EOF
Step 4: Handle File I/O
For scripts that need to read/write files:
- Use absolute or explicit relative paths
- Files persist in the workspace directory
- List directory contents with
lsto verify file operations
python3 << 'EOF'
import os
# Write output to file
with open("output.txt", "w") as f:
f.write("Results here")
# Verify
print(f"Working directory: {os.getcwd()}")
EOF
Code Examples
Simple Calculation
python3 << 'EOF'
result = sum(range(100))
print(f"Sum: {result}")
EOF
With Package Installation
pip install requests -q && python3 << 'EOF'
import requests
response = requests.get("https://api.example.com/data")
print(response.json())
EOF
With JSON Processing
python3 << 'EOF'
import json
data = {"key": "value", "count": 42}
output = json.dumps(data, indent=2)
print(output)
# Save to file
with open("data.json", "w") as f:
f.write(output)
EOF
Best Practices
- Use heredoc syntax -
<< 'EOF'prevents variable expansion issues - Install quietly - Use
pip install -qto reduce output noise - Error handling - Add try/except blocks in Python code for robustness
- Verify execution - Check stdout/stderr from run_shell to confirm success
- Keep code compact - Long scripts are harder to debug in shell context
Caveats
- No persistent state between run_shell calls (unlike execute_code_sandbox)
- Longer execution time for complex scripts due to Python interpreter startup
- Limited debugging - Cannot easily inspect variables between statements
- Output size limits - Very large outputs may be truncated
When NOT to Use This Fallback
- If the task specifically requires sandbox isolation for security
- If you need persistent state across multiple code executions
- If the code execution is extremely long-running (consider backgrounding)
FAQ
How does the agent check the output?
It reads the messages from the shell and lists the folder to see the new files.
Why use explicit paths?
Explicit paths make sure files are saved in the workspace folder you expect.
Does this work without installing anything?
If the packages are already present, the install step can be skipped.
Details
Original description by the author
Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12992
- 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.