| name | sandbox-failure-recovery |
| description | Recover from execute_code_sandbox failures by writing code to file and executing via run_shell |
Sandbox Failure Recovery Workflow
When execute_code_sandbox fails (often due to infrastructure issues, timeouts, or complex dependencies), use this recovery pattern to achieve identical results by writing the code to a file and executing it directly.
When to Use This Skill
execute_code_sandbox returns an error or times out
- The task involves spreadsheet generation (Excel, CSV) or file output
- You have working Python code that needs to be executed
- The sandbox environment appears unstable
Step-by-Step Instructions
Step 1: Preserve the Failed Code
When execute_code_sandbox fails, capture the Python code that was attempted. If the code was generated but not saved, reconstruct it from the execution attempt.
Step 2: Write Code to File
Use write_file to save the Python script to a .py file:
write_file with:
- path: "script_name.py" (e.g., "generate_report.py", "process_data.py")
- content: <the full Python code>
Example:
import pandas as pd
from openpyxl import Workbook
df = pd.DataFrame({'Revenue': [100, 200, 300]})
df.to_excel('output.xlsx', index=)