code-exec-fallback
できること
このスキルは、内蔵のランナーが繰り返し失敗するときのPythonの予備の実行方法です。データや計算のスクリプトを、それでも動かしたい人向けです。
使う場面
- ✓制限、タイムアウト、不足したパッケージのために、コードの実行が2回以上失敗したとき。
- ✓データのスクリプトを、設定された時間制限のもとでシェルから実行したいとき。
- ✓実行の出力を読み、エラーを報告してほしいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/code-exec-fallback/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Pythonの実行環境が、スプレッドシートの処理でタイムアウトし続けています。スクリプトをファイルに保存して、代わりに実行してもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIはスクリプトをファイルに書き、シェルでpython3を使って実行し、設定された時間まで待ち、出力を読みます。その後、ファイルは削除できます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Code Execution Fallback
When to Use
Use this pattern when execute_code_sandbox fails repeatedly (typically 2+ attempts) due to environment limitations, timeouts, dependency issues, or sandbox restrictions.
The Pattern
Instead of executing code directly in the sandbox, write the Python script to a file and execute it via shell:
- Write the script using
write_file - Execute via shell using
run_shellwithpython3 script.py - Clean up (optional) remove the temporary file
Step-by-Step Instructions
Step 1: Write the Python Script
Use write_file to save your Python code:
- Path: Choose a descriptive name (e.g., "process_data.py", "analyze.py")
- Content: Your complete Python script with all imports and logic
Step 2: Execute via Shell
Use run_shell to execute:
- Command: "python3 <script_name>.py"
- Timeout: Set appropriately for your task (default 30s, increase if needed)
Step 3: Handle Output
- Capture stdout/stderr from run_shell
- Parse results as needed
- Optionally delete the script file after execution
Example
# Instead of this (which may fail):
execute_code_sandbox(code="import pandas as pd; df = pd.read_csv('data.csv')...")
# Do this:
write_file(path="analyze.py", content="""
import pandas as pd
import json
df = pd.read_csv('data.csv')
result = df.groupby('category').sum()
print(json.dumps(result.to_dict()))
""")
run_shell(command="python3 analyze.py", timeout=60)
Tips for Success
- Include all imports in the script file - the shell environment may differ from the sandbox
- Use absolute paths or ensure working directory is correct
- Add error handling to your script for better debugging
- Increase timeout for long-running operations (default is 30s)
- Print structured output (JSON) if you need to parse results
- Clean up temporary files after successful execution to avoid clutter
When This Helps
- Sandbox has missing dependencies
- Code execution times out in sandbox but would work in shell
- File I/O operations are restricted in sandbox
- Need to run external commands or system utilities
- Complex multi-file projects that need proper file structure
よくある質問
ランナーの代わりにファイルを使う理由は?
この経路は、一部の失敗の場合に、より信頼できることが実証されているとガイドは述べています。
デフォルトの時間制限は?
デフォルトは30秒で、タスクにより長い時間が必要なら引き上げられます。
スクリプトに特別な設定は必要ですか?
スクリプトは、必要なインポートとすべてのロジックを含み、単独で動く必要があります。
詳細
作者による元の説明
Fallback pattern for executing Python code when execute_code_sandbox fails
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12845
- ライセンス
- 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のイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。