debug-sandbox-execution
できること
このスキルは、あいまいな部分的なエラーで失敗するPythonコードの実行を、デバッグする方法です。どのステップが壊れたかを見つけ、コードを再び動かしたい人向けです。
使う場面
- ✓原因不明のエラーで、コードの実行が失敗したり出力が途中で止まったりするとき。
- ✓スクリプトがいくつかのファイルを作るのに、一部しか現れないとき。
- ✓失敗しているステップを見つけるために、スクリプトの各部分を個別に試したいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/debug-sandbox-execution/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Pythonスクリプトが途中で、はっきりしたエラーもなく止まります。どの部分が失敗しているか、一緒に探してもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIはスクリプトを再実行して、失敗する前に出た出力を取り込み、各関数を単独で試し、各結果を順に確かめて原因を探します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Debug Sandbox Execution Failures
When execute_code_sandbox fails with unknown errors or incomplete output, use this debugging pattern to identify the root cause and recover incrementally.
Problem
The execute_code_sandbox tool may fail silently, truncate output, or produce opaque errors. Complex scripts with multiple file outputs are especially prone to partial failures.
Solution
Use a three-phase debugging approach:
Phase 1: Capture Partial Execution Traces
When a sandbox execution fails, rerun the code using run_shell with output piping to capture whatever output is produced before the failure:
python your_script.py 2>&1 | head -100
This reveals:
- Which functions/steps executed successfully
- Where the failure occurred
- Any error messages that were suppressed
Phase 2: Isolate Failing Functions
Break the script into smaller, testable units. Execute each function or code block independently:
# Test individual components
if __name__ == "__main__":
# Step 1: Test imports
import numpy as np
print("Imports OK")
# Step 2: Test function A in isolation
result_a = function_a()
print(f"Function A: {result_a}")
# Step 3: Test function B
result_b = function_b(result_a)
print(f"Function B: {result_b}")
Run each section with execute_code_sandbox separately to identify which component fails.
Phase 3: Incremental Output Generation
Generate output files one at a time, verifying each before proceeding:
import numpy as np
import soundfile as sf
# Generate and save file 1
audio1 = np.random.randn(48000 * 10).astype(np.float32)
sf.write('output_01.wav', audio1, 48000, subtype='FLOAT')
# Verify file 1 exists and has expected properties
import os
assert os.path.exists('output_01.wav'), "File 1 not created"
# Generate and save file 2
audio2 = np.random.randn(48000 * 10).astype(np.float32)
sf.write('output_02.wav', audio2, 48000, subtype='FLOAT')
# Verify file 2
assert os.path.exists('output_02.wav'), "File 2 not created"
Example Workflow
- Initial attempt: Run full script with
execute_code_sandbox - On failure: Rerun with
run_shelland| head -100to see partial output - Identify breakpoint: Find the last successful operation
- Split script: Create separate scripts for each major section
- Test incrementally: Run each section, verify outputs, proceed to next
- Combine successful sections: Once all pieces work, combine into final script
Best Practices
- Always verify file creation immediately after writing:
assert os.path.exists(path) - Check file properties (size, duration, format) before assuming success
- Use print statements liberally to mark progress through the script
- Save intermediate outputs so failures don't require restarting from scratch
- Test audio/video generation with short samples first (1-2 seconds) before full-length content
When to Use
- Complex scripts with multiple file outputs
- Audio/video generation pipelines
- Scripts with external library dependencies
- Any
execute_code_sandboxcall that produces incomplete or no output
よくある質問
なぜ部分的な出力を取り込むのですか?
どのステップが成功し、どこで失敗したかを示すからです。
AIがコードそのものを直しますか?
主に原因を見つけ、段階を追って回復させます。修正は、見つかった内容から導かれます。
どのコマンドを使いますか?
結果を取り込むためにシェルの出力のパイプを使い、コードの各ブロックを別々に試します。
詳細
作者による元の説明
Debug Python code execution failures by capturing partial traces, isolating failing functions, and incrementally verifying outputs
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12850
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。