本文へスキップ
Skillpedia
一般的なプログラミング7.8k · #12983

sandbox-exec-fallback

できること

このスキルは、AIエージェントがコードサンドボックスから、シェルで実行する保存済みのPythonファイルに切り替える方法を示します。Pythonでスプレッドシート、データ出力、その他のファイルを作る人向けです。

使う場面

  • ✓スプレッドシートやCSVファイルを作成中に、コードサンドボックスが失敗したとき。
  • ✓データ処理の作業がサンドボックスで失敗し、それでも出力が必要なとき。
  • ✓長い処理やメモリを多く使うPythonの処理に、サンドボックスの制限より多くの時間が必要なとき。

スキルのリンク

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-exec-fallback/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-exec-fallback/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“経費のスプレッドシートを作成中にサンドボックスが失敗しました。Pythonコードをファイルに保存して実行し、スプレッドシートが作られたか確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは完全なPythonコードをスクリプトファイルに書き出し、時間制限を付けてシェルでpython3を実行します。表示された出力を確認し、スクリプトが作成したファイルを探すためにフォルダーの一覧を表示します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Sandbox Execution Fallback

When to Use

Use this skill when execute_code_sandbox fails during Python code execution, particularly for tasks involving:

  • Spreadsheet generation (xlsx, csv)
  • Data processing and transformations
  • File output operations
  • Complex computations requiring libraries

Recovery Pattern

When execute_code_sandbox returns an error or fails to produce expected output:

Step 1: Write Python Code to File

Use write_file to save your Python script to a file:

# Use write_file tool with:
path: "script.py"
content: <your complete Python code as a string>

Step 2: Execute via Shell

Use run_shell to execute the script:

# Use run_shell tool with:
command: "python3 script.py"
timeout: <appropriate timeout, e.g., 300 for long-running tasks>

Step 3: Verify Output

Check the shell output for:

  • Success messages or printed results
  • Error messages (if any, diagnose and fix the script)
  • File creation confirmations

Step 4: Access Generated Files

If the script creates output files (e.g., spreadsheets), they will be in the current working directory. Use list_dir to confirm, then read_file to access if needed.

Why This Works

  • Same Python Environment: python3 in the shell uses the same environment as the sandbox
  • More Robust: Shell execution handles long-running or memory-intensive tasks better
  • Debuggable: Errors are captured in stdout/stderr for easier diagnosis
  • Identical Results: Produces the same output as sandbox execution when successful

Example: Spreadsheet Generation

Original code that failed in execute_code_sandbox:

import pandas as pd

data = {'A': [1, 2, 3], 'B': [4, 5, 6]}
df = pd.DataFrame(data)
df.to_excel('output.xlsx', index=False)
print("File created successfully")

Recovery Execution:

  1. write_file with path="generate_spreadsheet.py" and the code above as content
  2. run_shell with command="python3 generate_spreadsheet.py"
  3. Verify output.xlsx was created with list_dir

Tips

  • Increase timeout for complex operations (default 30s may be insufficient)
  • Add explicit print statements for debugging
  • Handle exceptions in your script and print error messages
  • Clean up temporary script files after successful execution if needed
よくある質問

出力ファイルはどこに保存されますか?

スキルでは、出力ファイルは現在のワーキングフォルダーに作られると説明しているため、エージェントはそのフォルダーを一覧表示してファイルを探します。

スクリプトはどのくらい実行できますか?

長い処理には、300秒などより長いタイムアウトを設定するよう提案しています。

スクリプトがまだ失敗する場合はどうしますか?

エラーメッセージを読み、スクリプトを修正して再実行するよう述べています。

詳細

作者による元の説明

Fallback pattern for executing Python code when execute_code_sandbox fails by writing to file and running via shell

repo: HKUDS/AgentPilot

人気

GitHubのスター
7.8k
ランキング
#12983
ライセンス
MIT
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル