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

sandbox-execution-fallback

できること

このスキルは、AIエージェントが失敗したコード実行から回復する方法を示します。コードを.pyファイルに保存し、シェルで実行します。スプレッドシートやデータ処理がサンドボックスでタイムアウトする人向けです。

使う場面

  • ✓スプレッドシートやデータ処理のジョブでコードサンドボックスがタイムアウトしたとき。
  • ✓pandasやopenpyxlなどの外部ライブラリが必要な処理のとき。
  • ✓長い計算がサンドボックスの時間制限に何度も達するとき。

スキルのリンク

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

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“pandasの処理がサンドボックスでタイムアウトします。コードをファイルに保存し、制限時間を長くしてシェルで実行してください。”

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

仕組み

エージェントは失敗したコードを取り出し、分かりやすい名前の.pyファイルに書き出します。システムのPythonで実行し、想定したファイルと結果が作られているか確認します。

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

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

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

Aspect execute_code_sandbox run_shell + write_file
Environment Sandboxed, limited Full system Python
File I/O Restricted Full access
Timeout Strict limits More flexible
Library Support May be limited System-installed packages
Result Identical output Identical 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
よくある質問

コードが失われていた場合、エージェントは回復できますか?

はい。スキルは、保存されていない場合は失敗した試行からコードを再構成するよう述べています。

どのPythonコマンドを使いますか?

スキルは、シェルからpython3でスクリプトを実行します。

エージェントはどのように成功を確認しますか?

ファイルが作られ、データが想定どおりに処理されたかを確認します。

詳細

作者による元の説明

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

repo: HKUDS/AgentPilot

人気

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

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

0

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

コメント

  • …

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

似ているスキル