code-exec-fallback-266cba
できること
このスキルは、内蔵のコード実行環境が繰り返し失敗するときに、AIに方法を切り替えるよう指示します。Pythonのコードを実行して成功させる必要があるAIタスクの人向けです。
使う場面
- ✓原因の分からないエラーで、サンドボックスが2回連続で失敗したとき。
- ✓再試行しても実行がタイムアウトし続けるとき。
- ✓サンドボックスではなく、コマンドラインからPythonスクリプトを実行する必要があるとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/code-exec-fallback-266cba/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“データのスクリプトについて、コード実行環境で失敗し続けています。別の方法で実行して、出力を見せてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIはPythonのコードをファイルに書き、シェルコマンドで実行し、出力とエラーを読み、成功したかどうかを報告します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Code Execution Fallback Pattern
When to Use This Skill
Apply this pattern when you encounter repeated failures with execute_code_sandbox:
- 2+ consecutive failures with opaque or unknown errors
- Timeout errors that persist across retry attempts
- Environment-related errors that don't resolve with code fixes
The Fallback Workflow
Step 1: Detect Repeated Failures
Track execution failures. After 2 consecutive failures with execute_code_sandbox, switch to the fallback approach.
Step 2: Write Script to File
Use write_file to save your Python script:
write_file(
path="/workspace/script_name.py",
content="# Your Python code here\nimport sys\n..."
)
Step 3: Execute via Shell
Use run_shell to run the script:
run_shell(
command="python /workspace/script_name.py",
timeout=300
)
Step 4: Capture Output
Parse stdout/stderr from run_shell output to verify success or diagnose issues.
Complete Example
# Instead of this (which may fail):
result = execute_code_sandbox(code="import pandas as pd\n...")
# Use this fallback pattern:
script_content = """
import pandas as pd
import sys
try:
# Your logic here
df = pd.DataFrame({'col': [1, 2, 3]})
print(df.to_csv())
sys.exit(0)
except Exception as e:
print(f"ERROR: {e}", file=sys.stderr)
sys.exit(1)
"""
# Write the script
write_file(path="/workspace/my_script.py", content=script_content)
# Execute via shell
result = run_shell(command="python /workspace/my_script.py", timeout=300)
Best Practices
- Add error handling in your script - use try/except with
sys.exit()codes - Set appropriate timeouts -
run_shelldefault is 30s, increase for heavy operations - Clean up temporary files after execution if needed
- Log the fallback trigger - document why you switched approaches
- Verify Python availability - Most sandboxes have Python 3.x by default
Why This Works
write_fileis more reliable for file I/O operationsrun_shellgives you direct control over execution environment- Shell execution bypasses sandbox serialization issues
- Better error visibility through stdout/stderr streams
When NOT to Use This Pattern
- First-time execution failures (retry the sandbox first)
- Simple one-liner code (sandbox is faster)
- When sandbox errors are clearly code bugs (fix the code instead)
- Security-sensitive operations requiring sandbox isolation
よくある質問
何を失敗とみなしますか?
ガイドは、サンドボックスからの繰り返しのエラー、原因不明のエラー、タイムアウトを挙げています。
エラーを見られますか?
はい。出力とエラーメッセージが取得されるので、AIは何が問題だったかを報告できます。
なぜコードをファイルに書くのですか?
サンドボックスが繰り返し失敗した場合、この経路は機能することがあるとガイドは述べています。
詳細
作者による元の説明
Fallback workflow for reliable code execution when sandbox fails repeatedly
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12844
- ライセンス
- 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エージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。