sandbox-execution-fallback-717e65
What it does
This skill helps the AI agent move from a code sandbox that keeps failing to saved script files run in the shell. It is for people whose sandbox is unstable or times out.
When to use it
- ✓When the code sandbox fails again after two or three retries.
- ✓When the error points to a service problem rather than a bug in your code.
- ✓When complex code with file reading and writing needs clearer error messages.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-execution-fallback-717e65/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 keeps timing out on my data job. Write it as a script and run it from the shell so I can see the errors.”
5 new skills a week. 1 minute to read.
How it works
The agent writes the Python code to a file, and if needed splits a larger job into several files. It runs the script through the shell and reads the output and any errors to decide the next step.
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 repeatedly or exhibits instability. Common triggers include:
- Sandbox returns errors after 2-3 retry attempts
- Error messages indicate provider/system issues rather than code bugs
- Execution times out or hangs inconsistently
- Complex multi-step code with file I/O is needed
- Better error visibility and debugging is required
Procedure
Step 1: Detect When to Switch
Recognize the failure pattern:
execute_code_sandboxproduces repeated errors despite code corrections- Error output suggests infrastructure issues (not syntax/logic errors)
- The sandbox environment appears unstable or limited
Step 2: Write Python Script to File
Use write_file to save your script:
write_file(
path="script.py",
content="#!/usr/bin/env python3
# Your Python code here
import sys
print('Executing via file-based approach')
# ... rest of your code
"
)
For multi-file projects, write each file separately:
write_file(path="utils.py", content="# Utility functions\ndef helper(): ...")
write_file(path="main.py", content="from utils import helper\nhelper()")
Step 3: Execute via Shell
Run the script using run_shell:
run_shell(command="python3 script.py")
For scripts in subdirectories:
run_shell(command="cd mydir && python3 script.py")
Step 4: Handle Output and Clean Up
- Parse stdout/stderr from
run_shelloutput - Inspect created files directly using
read_fileif needed - Remove temporary scripts after successful execution:
run_shell(command="rm script.py")
Advantages Over Sandbox Execution
| Benefit | Explanation |
|---|---|
| Bypasses provider limitations | No sandbox resource constraints |
| Better error visibility | Full stack traces and system errors |
| Environment control | Direct access to system Python and packages |
| Multi-file support | Easy imports and module structure |
| Persistence | Files remain for inspection and debugging |
| Reliability | More consistent execution behavior |
Complete Example
# Scenario: execute_code_sandbox failing on data processing task
# Step 1: Write the script
write_file(
path="process_data.py",
content="#!/usr/bin/env python3
import json
import csv
# Load and process data
with open('input.json', 'r') as f:
data = json.load(f)
# Transform data
results = []
for item in data:
results.append({'processed': item['value'] * 2})
# Write output
with open('output.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=['processed'])
writer.writeheader()
writer.writerows(results)
print('Processing complete')
"
)
# Step 2: Execute via shell
run_shell(command="python3 process_data.py")
# Step 3: Read results
read_file(filetype="csv", file_path="output.csv")
# Step 4: Clean up (optional)
run_shell(command="rm process_data.py")
Best Practices
- Use absolute or clear relative paths - Avoid ambiguity in file locations
- Add error handling in scripts - Catch exceptions and print meaningful messages
- Validate script content before writing - Ensure proper Python syntax
- Log execution steps - Track what was written and executed for debugging
- Clean up temporary files - Remove scripts after use unless needed for later inspection
Troubleshooting
| Issue | Solution |
|---|---|
python3 not found |
Try python or specify full path /usr/bin/python3 |
| Import errors | Use run_shell(command="pip3 install package") first |
| Permission denied | Add execute permission: run_shell(command="chmod +x script.py") |
| Working directory issues | Use absolute paths or cd in the command |
FAQ
How do I know the sandbox is the problem?
The skill says to switch when errors suggest infrastructure trouble, such as repeated failures or timeouts, rather than code mistakes.
Can the job use several files?
Yes, the skill says to write each file separately and run the main file, which imports the others.
Can scripts in subfolders run?
Yes, the skill shows changing into the subfolder before running the script.
Details
Original description by the author
Fallback from execute_code_sandbox to file-based run_shell execution when sandbox fails
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12985
- 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.