跳到正文
cccskills
免费在 GitHub 公开

execute-code-fallback

Continue Python tasks when the e2b sandbox, an isolated execution environment, is unavailable. Guides switching from execute_code_sandbox to run_shell, preparing dependencies, checking execution results, and saving intermediate data between calls.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Fallback from execute_code_sandbox to run_shell when e2b sandbox is unavailable

查看安装方法

适用场景

  • Continue Python processing during an e2b service outage
  • Run CSV summaries after sandbox connection failures
  • Execute multiline Python scripts through run_shell
  • Save intermediate results between execution calls

包含的文件(2)

  • SKILL.md4.0 KB
  • .skill_id35 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Execute Code Fallback Pattern

When execute_code_sandbox fails due to e2b unavailability, immediately fall back to run_shell with embedded Python code. This ensures task continuity when the sandbox service is down.

When to Apply

Use this pattern when you observe:

  • execute_code_sandbox returns errors mentioning "e2b", "sandbox unavailable", or connection timeouts
  • Repeated sandbox execution failures (2+ attempts)
  • Error messages indicating the code execution environment is unreachable

Fallback Procedure

Step 1: Detect the Failure

Identify that execute_code_sandbox has failed. Common error indicators:

  • "e2b service unavailable"
  • "Sandbox connection failed"
  • "Execution environment not reachable"
  • Timeout errors during code execution

Step 2: Switch to run_shell with Embedded Python

Instead of:

execute_code_sandbox(code="...")

Use:

run_shell(command="python3 -c '...your Python code...'")

Step 3: Install Dependencies First (If Needed)

If your Python code requires external packages, install them first:

run_shell(command="pip install pandas requests matplotlib")

Then execute your main code:

run_shell(command="python3 << 'EOF'
import pandas as pd
import requests

# Your code here
print("Success")
EOF
")

Step 4: Use Heredoc for Multi-line Code

For complex Python scripts, use heredoc syntax for cleaner code:

run_shell(command="python3 << 'PYTHON_SCRIPT'
import json
import os

# Complex logic here
data = {'key': 'value'}
with open('output.json', 'w') as f:
    json.dump(data, f)

print('File created successfully')
PYTHON_SCRIPT
")

Complete Example

Scenario: You need to process a CSV file and generate a report.

Original approach (sandbox):

execute_code_sandbox(code="""
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
""")

Fallback approach (run_shell):

# First install dependencies if needed
run_shell(command="pip install pandas --quiet")

# Then execute the code
run_shell(command="python3 << 'EOF'
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
EOF
")

Important Considerations

  1. State Persistence: Unlike execute_code_sandbox, run_shell executions may not share state between calls. Save intermediate results to files if needed.

  2. Working Directory: Ensure you're operating in the correct directory. Use pwd to verify or include cd /path/to/workdir in your commands.

  3. Python Version: Use python3 explicitly to avoid ambiguity. Verify with python3 --version if needed.

  4. Error Handling: Check the stdout/stderr from run_shell to confirm success. Failed Python scripts will return non-zero exit codes.

  5. Security: Be cautious when embedding user-provided data into shell commands. Escape appropriately or use file-based input.

  6. Performance: For large computations, run_shell may be slower than sandbox. Consider breaking into smaller steps if timeouts occur.

Quick Reference

TaskSandbox ApproachFallback Approach
Simple calculationexecute_code_sandbox(code="print(2+2)")run_shell(command="python3 -c 'print(2+2)'")
Install + runexecute_code_sandbox(code="import pkg; ...")run_shell(command="pip install pkg && python3 -c '...'")
Multi-line scriptexecute_code_sandbox(code="...")run_shell(command="python3 << 'EOF'...EOF")
File I/Oexecute_code_sandbox(code="...")run_shell(command="python3 << 'EOF'...EOF")

Recovery Checklist

  • Confirm execute_code_sandbox failure (not a code bug)
  • Switch to run_shell immediately
  • Install required packages with pip install
  • Use heredoc for multi-line Python
  • Verify output and handle errors
  • Save intermediate results to files if multi-step

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

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/OpenSpace77572026年8月13日 更新

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/OpenSpace77572026年8月13日 更新

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/OpenSpace77572026年8月13日 更新

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/OpenSpace77572026年8月13日 更新

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/OpenSpace77572026年8月13日 更新

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/OpenSpace77572026年8月13日 更新

查看 HKUDS 的全部技能

报告此技能的问题