fallback-code-execution
できること
このスキルは、サンドボックスが原因不明で不安定なエラーを返し続けるときに、Pythonのコードを実行する回避策です。コードが結果を出す必要があるAIの作業をしている人向けです。
使う場面
- ✓同じコードで、サンドボックスが2回以上連続で失敗したとき。
- ✓エラーが一般的で、コードの誤りではなく環境の問題を示唆するとき。
- ✓スクリプトを確認し、再び実行できるようファイルとして残したいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-code-execution/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“サンドボックスが私のスクリプトで一般的なエラーを出し続けます。ロジックは正しいので、ファイルとして保存して実行してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、作業フォルダの中に分かりやすい名前でスクリプトを書き、先に依存関係をインストールし、出力を取り込みながらシェルで実行します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Fallback Code Execution Workflow
Overview
This skill defines a robust workaround for executing code (specifically Python) when the primary execute_code_sandbox tool fails repeatedly with unknown or transient errors. Instead of continuing to retry the failing tool, the agent switches to a manual file-write and shell-execution pattern.
Trigger Conditions
Activate this workflow when:
execute_code_sandboxfails 2 or more times consecutively for the same logic.- Error messages are generic, unknown, or indicate environment issues rather than syntax errors.
- The code logic itself is verified correct but the execution environment is unstable.
Procedure
Step 1: Write Script to File
Use the write_file tool to save the Python script to a specific path in the workspace.
- Path: Choose a descriptive name ending in
.py(e.g.,scripts/generate_report.py). - Content: Ensure the script includes necessary error handling and print statements for debugging.
- Dependencies: If the script requires external libraries, ensure a
requirements.txtis updated or installed via shell beforehand.
Example:
tool: write_file
path: workspace/scripts/process_data.py
content: |
import sys
# ... script logic ...
print("Success")
Step 2: Execute via Shell
Use the run_shell tool to execute the script using the system Python interpreter.
- Command:
python3 <path_to_script>orpython <path_to_script>. - Working Directory: Ensure the shell command runs from the workspace root or the directory containing the script.
- Capture Output: Store stdout and stderr for verification.
Example:
tool: run_shell
command: python3 scripts/process_data.py
Step 3: Verify Execution
- Check Exit Code: Ensure the shell command returned exit code
0. - Check Output: Verify expected files were created or expected stdout messages appeared.
- Handle Errors: If the shell execution fails, inspect the stderr output. This often provides more detailed tracebacks than the sandbox tool.
Best Practices
- Absolute Paths: When writing scripts that access files, use absolute paths or resolve paths relative to
__file__to avoid working directory issues. - Permissions: Ensure the workspace directory allows file creation and execution.
- Cleanup: Optionally remove temporary scripts after successful execution if cleanliness is required.
- Logging: Add explicit
print()statements in the Python script to log progress, as shell output capture is sometimes more reliable than sandbox return values.
Example Scenario
Problem: execute_code_sandbox times out while generating a PDF.
Solution:
- Write
generate_pdf.pytoworkspace/scripts/. - Run
python3 workspace/scripts/generate_pdf.pyviarun_shell. - Confirm
output.pdfexists in the workspace.
よくある質問
なぜスクリプトをファイルとして残すのですか?
保存されたファイルは、コードを書き直さずに、確認、修正、再実行できるからです。
スクリプトはどこに保存されますか?
作業フォルダに、分かりやすい名前で拡張子.pyを付けて保存されます。
パッケージが必要な場合は?
ガイドは、先に要件ファイルまたはシェルを通じてインストールするよう述べています。
詳細
作者による元の説明
Fallback workflow for running code via file write and shell when sandbox execution fails
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12879
- ライセンス
- 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のイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。