code-execution-fallback-e81068
できること
このスキルは、原因不明のエラーや止まってしまうエラーがサンドボックスで出るときに、Pythonを実行するための予備の方法をAIに与えます。結果を出すことが必要なコードに依存するAIタスクの人向けです。
使う場面
- ✓サンドボックスが、原因不明のエラーを2回連続で返したとき。
- ✓明確な理由がないまま、コードの実行が止まったりタイムアウトしたりするとき。
- ✓自己完結したスクリプトをファイルとして保存し、後で結果を確認したいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/code-execution-fallback-e81068/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 Workflow
When to Use
Use this skill when execute_code_sandbox fails repeatedly (2+ attempts) with unknown, persistent, or unexplained errors. This fallback approach uses write_file + run_shell to save Python scripts to disk and execute them via command line, which has proven more reliable in certain failure scenarios.
Step-by-Step Instructions
Step 1: Detect Repeated Failures
Monitor execute_code_sandbox attempts. After 2 consecutive failures with errors like:
- "Unknown error"
- Timeout errors
- Unexplained execution failures
- Sandbox environment issues
Switch to the fallback workflow immediately.
Step 2: Write the Python Script to File
Use write_file to save your Python code as a .py file in the working directory:
write_file(
path="script.py",
content="""
import sys
import json
# Your Python code here
def main():
# Your logic
result = {"status": "success", "data": "example"}
print(json.dumps(result))
if __name__ == "__main__":
main()
"""
)
Tips:
- Use clear, self-contained code that doesn't rely on sandbox-specific paths
- Include error handling and informative print statements
- Save output to files if needed for later retrieval
Step 3: Execute via Shell
Use run_shell to execute the Python script via command line:
run_shell(
command="python3 script.py",
timeout=60 # Adjust timeout as needed
)
Alternative commands:
python script.py- if python3 alias isn't availablepython3 -u script.py- for unbuffered outputpython3 script.py arg1 arg2- with arguments
Step 4: Verify Output and Results
Check the stdout/stderr from run_shell to:
- Confirm execution succeeded (exit code 0)
- Inspect printed output or results
- Identify any new errors (different from sandbox errors)
If the script writes output files, use read_file to retrieve results.
Step 5: Clean Up (Optional)
Remove temporary script files if they won't be reused:
run_shell(command="rm script.py")
Complete Example
Scenario: execute_code_sandbox failed twice while trying to process data.
Fallback execution:
# Step 1: Write the processing script
write_file(
path="process_data.py",
content="""
import pandas as pd
import json
def process():
data = [1, 2, 3, 4, 5]
result = {"sum": sum(data), "count": len(data)}
print(json.dumps(result))
# Also save to file for reliability
with open("result.json", "w") as f:
json.dump(result, f)
if __name__ == "__main__":
process()
"""
)
# Step 2: Execute via shell
output = run_shell(command="python3 process_data.py")
# Step 3: Read results from file
results = read_file(file_path="result.json", filetype="json")
Troubleshooting
| Issue | Solution |
|---|---|
python3: command not found |
Try python instead, or check available interpreters with which python |
| Permission denied | Ensure the working directory is writable; write_file creates files in workspace by default |
| Module not found | Install dependencies via run_shell(command="pip install package_name") before execution |
| Script hangs | Increase timeout parameter in run_shell |
| Output too long | Redirect output to file within the script and read it separately |
Best Practices
- Always include error handling in scripts to capture failures gracefully
- Write results to files in addition to printing, for reliable retrieval
- Use descriptive filenames to avoid conflicts (e.g.,
task_specific_script.py) - Keep scripts self-contained - avoid dependencies on sandbox environment variables
- Log execution details for debugging:
print(f"Step X complete: {value}")
When NOT to Use This Fallback
- When sandbox isolation is required for security
- When the task explicitly requires
execute_code_sandbox - When
execute_code_sandboxsucceeds consistently (no need to add complexity) - When working with sensitive data that shouldn't persist to disk
よくある質問
どんなコードがファイルに向いていますか?
エラー処理と、わかりやすい表示メッセージを備えた、自己完結したコードがよいとガイドは述べています。
スクリプトはどこに保存されますか?
作業フォルダにファイルとして書かれるので、サンドボックスのパスに依存しません。
出力も保存できますか?
はい。ガイドは、結果を後で取り出せるようにファイルに書けると述べています。
詳細
作者による元の説明
Fallback workflow for executing Python code when execute_code_sandbox fails repeatedly
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12846
- ライセンス
- 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のイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。