跳到正文
cccskills
免费在 GitHub 公开

sandbox-execution-fallback-717e65

Move Python execution to saved script files when execute_code_sandbox repeatedly fails or becomes unstable. The skill covers writing single or multiple files, running them through run_shell, inspecting outputs and errors, and removing temporary scripts afterward.

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

原文查看原文说明

Fallback from execute_code_sandbox to file-based run_shell execution when sandbox fails

查看安装方法

适用场景

  • Switch execution methods after repeated sandbox failures
  • Run Python code split across multiple files
  • Process JSON input and write CSV output
  • Inspect generated files and remove temporary scripts

包含的文件(2)

  • SKILL.md3.8 KB
  • .skill_id47 B

SKILL.md(原文)

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

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_sandbox produces 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_shell output
  • Inspect created files directly using read_file if needed
  • Remove temporary scripts after successful execution:
    run_shell(command="rm script.py")
    

Advantages Over Sandbox Execution

BenefitExplanation
Bypasses provider limitationsNo sandbox resource constraints
Better error visibilityFull stack traces and system errors
Environment controlDirect access to system Python and packages
Multi-file supportEasy imports and module structure
PersistenceFiles remain for inspection and debugging
ReliabilityMore 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

  1. Use absolute or clear relative paths - Avoid ambiguity in file locations
  2. Add error handling in scripts - Catch exceptions and print meaningful messages
  3. Validate script content before writing - Ensure proper Python syntax
  4. Log execution steps - Track what was written and executed for debugging
  5. Clean up temporary files - Remove scripts after use unless needed for later inspection

Troubleshooting

IssueSolution
python3 not foundTry python or specify full path /usr/bin/python3
Import errorsUse run_shell(command="pip3 install package") first
Permission deniedAdd execute permission: run_shell(command="chmod +x script.py")
Working directory issuesUse absolute paths or cd in the command

评价

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

评论

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

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

提交后会立即公开。请勿填写邮箱、电话等个人信息。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 的全部技能

报告此技能的问题