Skip to content
cccskills
FreePublished on GitHub

sandbox-fallback-python

Continue Python work when the code sandbox is unavailable by running scripts through run_shell. The workflow covers recognizing connection failures, installing required packages, reading and writing workspace files, and checking execution results.

OriginalShow the original description

Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability

See how to install

Good for

  • Continuing calculations during an e2b outage
  • Running Python after a sandbox connection failure
  • Processing and saving JSON through the shell
  • Installing packages before running a fallback script

Files included (2)

  • SKILL.md3.1 KB
  • .skill_id37 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

Sandbox Fallback: Python via run_shell

When to Use This Skill

Apply this skill when execute_code_sandbox fails with errors indicating:

  • e2b service unavailability
  • Sandbox timeout or connection issues
  • Code execution environment not accessible

This fallback allows you to execute Python code directly via shell, bypassing the sandbox infrastructure.

Fallback Procedure

Step 1: Detect Sandbox Failure

Identify fallback necessity from error messages like:

  • "e2b unavailable"
  • "sandbox connection failed"
  • "execution environment error"
  • Timeout errors during code execution

Step 2: Switch to run_shell with Embedded Python

Instead of execute_code_sandbox, use run_shell with a Python heredoc or inline script:

python3 << 'EOF'
# Your Python code here
print("Hello from fallback execution")
EOF

Step 3: Install Dependencies First

If your Python code requires packages not guaranteed to be installed:

pip install package_name package_name2 && python3 << 'EOF'
# Your Python code here
import package_name
print("Code with dependencies executed")
EOF

Step 4: Handle File I/O

For scripts that need to read/write files:

  • Use absolute or explicit relative paths
  • Files persist in the workspace directory
  • List directory contents with ls to verify file operations
python3 << 'EOF'
import os
# Write output to file
with open("output.txt", "w") as f:
    f.write("Results here")
# Verify
print(f"Working directory: {os.getcwd()}")
EOF

Code Examples

Simple Calculation

python3 << 'EOF'
result = sum(range(100))
print(f"Sum: {result}")
EOF

With Package Installation

pip install requests -q && python3 << 'EOF'
import requests
response = requests.get("https://api.example.com/data")
print(response.json())
EOF

With JSON Processing

python3 << 'EOF'
import json

data = {"key": "value", "count": 42}
output = json.dumps(data, indent=2)
print(output)

# Save to file
with open("data.json", "w") as f:
    f.write(output)
EOF

Best Practices

  1. Use heredoc syntax - << 'EOF' prevents variable expansion issues
  2. Install quietly - Use pip install -q to reduce output noise
  3. Error handling - Add try/except blocks in Python code for robustness
  4. Verify execution - Check stdout/stderr from run_shell to confirm success
  5. Keep code compact - Long scripts are harder to debug in shell context

Caveats

  • No persistent state between run_shell calls (unlike execute_code_sandbox)
  • Longer execution time for complex scripts due to Python interpreter startup
  • Limited debugging - Cannot easily inspect variables between statements
  • Output size limits - Very large outputs may be truncated

When NOT to Use This Fallback

  • If the task specifically requires sandbox isolation for security
  • If you need persistent state across multiple code executions
  • If the code execution is extremely long-running (consider backgrounding)

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

See all skills by HKUDS

Report a problem with this skill