本文へ移動
cccskills
無料GitHub で公開

sandbox-execution-fallback

Recover from execute_code_sandbox failures by writing Python scripts to files and executing via run_shell

インストール方法を見る

含まれるファイル(2)

  • SKILL.md2.9 KB
  • .skill_id40 B

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Sandbox Execution Fallback

When to Use

Apply this pattern when execute_code_sandbox fails or times out, particularly for:

  • Spreadsheet generation (pandas, openpyxl, xlsxwriter)
  • Complex data processing with file I/O
  • Tasks requiring external library imports
  • Long-running computations that hit timeout limits

Recovery Procedure

Step 1: Capture the Python Code

Extract or reconstruct the Python code that failed in execute_code_sandbox.

Step 2: Write Code to File

Use write_file to save the script with a .py extension:

write_file(
    path="script_name.py",
    content="""
import pandas as pd
# Your implementation here
"""
)

Step 3: Execute via run_shell

Run the script using the system Python interpreter:

run_shell(command="python3 script_name.py")

Step 4: Verify Output

Confirm the results match expected outputs (files created, data processed correctly, etc.).

Complete Example

# Failed: execute_code_sandbox with pandas Excel generation

# Recovery - Step 1 & 2: Write script to file
write_file(
    path="generate_pnl_report.py",
    content="""
import pandas as pd
from openpyxl import Workbook

# Create sample data
data = {
    'Category': ['Revenue', 'Expenses', 'Tax'],
    'Amount': [10000, 3000, 500]
}
df = pd.DataFrame(data)

# Write to Excel
df.to_excel('pnl_report.xlsx', index=False)
print('Report generated: pnl_report.xlsx')
"""
)

# Step 3: Execute via shell
run_shell(command="python3 generate_pnl_report.py")

# Step 4: Verify file was created
run_shell(command="ls -la pnl_report.xlsx")

Why This Works

Aspectexecute_code_sandboxrun_shell + write_file
EnvironmentSandboxed, limitedFull system Python
File I/ORestrictedFull access
TimeoutStrict limitsMore flexible
Library SupportMay be limitedSystem-installed packages
ResultIdentical outputIdentical output

Best Practices

  1. Use descriptive filenames - e.g., generate_report.py, process_data.py
  2. Add error handling - Include try/except blocks in your script
  3. Print progress - Use print statements for debugging
  4. Clean up - Remove temporary scripts after successful execution if needed
  5. Verify results - Always confirm outputs before proceeding

Common Use Cases

  • Excel/CSV report generation
  • Data transformation pipelines
  • Batch file processing
  • API data aggregation
  • Chart and visualization creation

Troubleshooting

If run_shell also fails:

  1. Check Python is available: run_shell(command="python3 --version")
  2. Install missing packages: run_shell(command="pip3 install pandas openpyxl")
  3. Check file permissions and paths
  4. Review stderr output for specific errors

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification

日本語の概要は準備中です。原文の説明を表示しています。

HKUDS/OpenSpace7,7552026年8月13日 更新

Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies

日本語の概要は準備中です。原文の説明を表示しています。

HKUDS/OpenSpace7,7552026年8月13日 更新

Create serverless API proxy endpoints that hide API keys and provide a unified backend for the dashboard frontend. Designed for Vercel deployment.

日本語の概要は準備中です。原文の説明を表示しています。

HKUDS/OpenSpace7,7552026年8月13日 更新

End-to-end audio production workflow with stems, effects, archiving, and verification

日本語の概要は準備中です。原文の説明を表示しています。

HKUDS/OpenSpace7,7552026年8月13日 更新

Handle cascading data retrieval tool failures by falling back to embedded knowledge generation

日本語の概要は準備中です。原文の説明を表示しています。

HKUDS/OpenSpace7,7552026年8月13日 更新

Fallback pattern for executing Python code when execute_code_sandbox fails

日本語の概要は準備中です。原文の説明を表示しています。

HKUDS/OpenSpace7,7552026年8月13日 更新

HKUDS のスキルをすべて見る

このスキルの問題を報告する