sandbox-fallback-execution-048d5a
Fallback method to execute Python code when execute_code_sandbox fails with e2b errors
- License 许可
- MIT
- 所属仓库
- AG064/OpenSpace
- 最近更新
- 2026-10-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- sandbox-fallback-execution-048d5a
- description
- Fallback method to execute Python code when execute_code_sandbox fails with e2b errors
02 资源文件 1
- 其他.skill_id47 B
03 SKILL.md 正文
Sandbox Fallback Execution
When execute_code_sandbox repeatedly fails with e2b sandbox errors, use this fallback pattern to execute Python code directly on the host system.
When to Use
Use this skill when:
execute_code_sandboxfails with e2b-related errors- Multiple retry attempts (3+) have not resolved the issue
- The code does not require sandbox isolation
Steps
Step 1: Write Python Script to File
Use write_file to save your Python code as a .py file:
Tool: write_file
path: /workspace/script_name.py
content: |
# Your Python code here
import pandas as pd
# ... rest of code
Step 2: Execute via Shell
Use run_shell with explicit python3 path:
Tool: run_shell
command: python3 /workspace/script_name.py
timeout: 120
Step 3: Verify Output
Check the stdout/stderr from run_shell for:
- Successful execution messages
- Expected output or file creation confirmations
- Any errors that need debugging
Complete Example
# Instead of this (failing):
Tool: execute_code_sandbox
code: |
import pandas as pd
df = pd.DataFrame({'a': [1,2,3]})
df.to_excel('output.xlsx')
# Use this fallback:
Tool: write_file
path: /workspace/generate_report.py
content: |
import pandas as pd
# Create sample data
df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
# Save to Excel
df.to_excel('/workspace/output.xlsx', index=False)
print('File created successfully')
Tool: run_shell
command: python3 /workspace/generate_report.py
timeout: 120
Tips
- Use absolute paths in your Python script when reading/writing files
- Add print statements for debugging since you won't get interactive output
- Increase timeout if the script performs heavy computation
- Check working directory - scripts run from the workspace root by default
- Handle errors explicitly with try/except blocks and meaningful error messages
Common e2b Errors That Trigger This Fallback
E2B execution errorSandbox timeoutConnection refusedSandbox initialization failed- Repeated retry failures (3+ attempts)
When NOT to Use This Fallback
- When sandbox isolation is required for security
- When the code needs specific sandbox environment variables
- On first failure only - try
execute_code_sandboxretry first
04 同仓库更多 Skills
write-special-chars-ts-check
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.
write-special-chars-readback
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of /tmp helper scripts.
write-special-chars-heredoc
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.
worldmonitor-reference
Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.
virtual-list
Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations
verify-directory-structure
Diagnose and resolve file access issues by first verifying the directory structure.