sandbox-fallback-execution
What it does
This skill shows the AI agent a simple fallback for Python code when the sandbox fails or times out. It is for people who need a short Python job finished without the sandbox.
When to use it
- ✓When the code sandbox fails with unknown errors or timeouts.
- ✓When the sandbox has failed more than twice on the same job.
- ✓When a Python package needs to be installed before the code can run.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-execution/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 gave an unknown error on my script. Install pandas if needed and run the code through the shell.”
5 new skills a week. 1 minute to read.
How it works
The agent installs any needed packages with pip, then runs the Python code through the shell using a heredoc. It checks the output for success messages or errors before it goes on.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Sandbox Fallback Execution
When to Use This Skill
Use this pattern when execute_code_sandbox fails with unknown errors, timeouts, or persistent execution failures. This fallback bypasses sandbox restrictions by using run_shell with a Python heredoc script.
Pattern Overview
execute_code_sandbox fails → run_shell with pip install → Python heredoc execution
Step-by-Step Instructions
Step 1: Detect Sandbox Failure
Monitor for these failure indicators from execute_code_sandbox:
- Unknown or unexplained errors
- Repeated execution failures (>2 attempts)
- Timeout errors
- Environment/package availability issues
Step 2: Install Required Dependencies (If Needed)
Use run_shell to install any required Python packages:
pip install <package_name>
For multiple packages:
pip install package1 package2 package3
Step 3: Execute Python via Heredoc
Run Python code using a heredoc script with run_shell:
python3 << 'EOF'
# Your Python code here
import sys
print("Hello from fallback execution")
EOF
Key heredoc syntax notes:
- Use
<< 'EOF'(quoted) to prevent shell variable expansion - Use
<< EOF(unquoted) if you need shell variable interpolation - Close with
EOFon its own line
Step 4: Verify and Iterate
- Check stdout/stderr for success indicators
- If errors persist, inspect output and adjust the script
- Capture any generated artifacts (files, outputs) for verification
Complete Example
Scenario: Need to create a Word document but execute_code_sandbox keeps failing.
# Step 1: Install required package
pip install python-docx
# Step 2: Execute Python script via heredoc
python3 << 'EOF'
from docx import Document
doc = Document()
doc.add_heading('Proposal Document', 0)
doc.add_paragraph('This is the proposal content.')
doc.save('proposal.docx')
print("Document created successfully")
EOF
Best Practices
- Quote the heredoc delimiter (
'EOF') to avoid unintended shell expansion of Python code - Install packages first before running the script to ensure availability
- Print status messages in your script for easier debugging
- Save outputs to files when possible for verification
- Keep scripts focused - break complex tasks into multiple heredoc executions if needed
Troubleshooting
| Issue | Solution |
|---|---|
pip not found |
Try pip3 or python3 -m pip install |
| Script hangs | Add timeout to run_shell command |
| Permission errors | Check file paths are writable |
| Import errors | Verify package was installed successfully |
Related Tools
run_shell: Execute shell commands directlyexecute_code_sandbox: Primary Python execution tool (try first)shell_agent: For more complex multi-step shell tasks
FAQ
What is the difference between quoted and unquoted EOF?
A quoted end marker stops the shell from changing variables, while an unquoted one lets the shell fill them in.
Does the agent install packages?
Yes, if the code needs a package, the skill says to install it with pip first.
What if errors remain?
The skill says to read the output, adjust the code and run it again.
Details
Original description by the author
Fallback workflow for executing Python code when execute_code_sandbox fails
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12990
- 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.