sandbox-execution-fallback
What it does
This skill shows the AI agent how to recover a failed code run by saving the code to a .py file and running it in the shell. It is for people whose spreadsheet or data jobs time out in the sandbox.
When to use it
- ✓When the code sandbox times out on a spreadsheet or data job.
- ✓When a job needs external libraries such as pandas or openpyxl.
- ✓When a long computation keeps hitting the sandbox time limit.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-execution-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
“My pandas job times out in the sandbox. Save the code to a file and run it in the shell with a longer limit.”
5 new skills a week. 1 minute to read.
How it works
The agent takes the code that failed, writes it to a .py file with a clear name, runs it with the system Python, and checks that the expected files and results are there.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Sandbox Execution Fallback
When to Use
Apply this pattern when execute_code_sandbox fails or times out, particularly for:
- Spreadsheet generation (pandas, openpyxl, xlsxwriter)
- Complex data processing with file I/O
- Tasks requiring external library imports
- Long-running computations that hit timeout limits
Recovery Procedure
Step 1: Capture the Python Code
Extract or reconstruct the Python code that failed in execute_code_sandbox.
Step 2: Write Code to File
Use write_file to save the script with a .py extension:
write_file(
path="script_name.py",
content="""
import pandas as pd
# Your implementation here
"""
)
Step 3: Execute via run_shell
Run the script using the system Python interpreter:
run_shell(command="python3 script_name.py")
Step 4: Verify Output
Confirm the results match expected outputs (files created, data processed correctly, etc.).
Complete Example
# Failed: execute_code_sandbox with pandas Excel generation
# Recovery - Step 1 & 2: Write script to file
write_file(
path="generate_pnl_report.py",
content="""
import pandas as pd
from openpyxl import Workbook
# Create sample data
data = {
'Category': ['Revenue', 'Expenses', 'Tax'],
'Amount': [10000, 3000, 500]
}
df = pd.DataFrame(data)
# Write to Excel
df.to_excel('pnl_report.xlsx', index=False)
print('Report generated: pnl_report.xlsx')
"""
)
# Step 3: Execute via shell
run_shell(command="python3 generate_pnl_report.py")
# Step 4: Verify file was created
run_shell(command="ls -la pnl_report.xlsx")
Why This Works
| Aspect | execute_code_sandbox | run_shell + write_file |
|---|---|---|
| Environment | Sandboxed, limited | Full system Python |
| File I/O | Restricted | Full access |
| Timeout | Strict limits | More flexible |
| Library Support | May be limited | System-installed packages |
| Result | Identical output | Identical output |
Best Practices
- Use descriptive filenames - e.g.,
generate_report.py,process_data.py - Add error handling - Include try/except blocks in your script
- Print progress - Use print statements for debugging
- Clean up - Remove temporary scripts after successful execution if needed
- Verify results - Always confirm outputs before proceeding
Common Use Cases
- Excel/CSV report generation
- Data transformation pipelines
- Batch file processing
- API data aggregation
- Chart and visualization creation
Troubleshooting
If run_shell also fails:
- Check Python is available:
run_shell(command="python3 --version") - Install missing packages:
run_shell(command="pip3 install pandas openpyxl") - Check file permissions and paths
- Review stderr output for specific errors
FAQ
Can the agent recover the code if it was lost?
The skill says to rebuild the code from the failed attempt if it was not saved.
What Python command is used?
The skill runs the script with python3 from the shell.
How does the agent check success?
It confirms the files were created and the data was processed as expected.
Details
Original description by the author
Recover from execute_code_sandbox failures by writing Python scripts to files and executing via run_shell
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12986
- 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.