python-execution-fallback-9d4989
できること
このスキルは、サンドボックスのツールが壊れたときの、単純なPythonの予備の実行方法をAIエージェントに与えます。短いコードでも原因不明のエラーが出るツールを使っている人向けです。
使う場面
- ✓単純なprint文でも、コードのサンドボックスが不明なエラーを返すとき。
- ✓簡単なPythonの計算が必要で、サンドボックスが応答しないとき。
- ✓AIのマシンでPythonが動くかどうかを確かめたいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-execution-fallback-9d4989/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“コードのサンドボックスが失敗し続けています。このPythonの計算を別の方法で実行して、結果を見せてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、heredocを使ってPythonのコードをシェル経由で送り、コードをそのままPythonに渡します。最初に短いテストのprintを実行して、Pythonが使えることを確かめます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Python Execution Fallback
When to Use
Use this skill when execute_code_sandbox returns 'unknown error' or fails unexpectedly, even on simple Python code like print statements.
Solution
Switch to using run_shell with Python heredoc syntax instead of execute_code_sandbox.
Basic Syntax
python3 << 'EOF'
# Your Python code here
print("Hello World")
result = 2 + 2
print(f"Result: {result}")
EOF
How to Call
Instead of:
execute_code_sandbox(code="print('Hello')")
Use:
run_shell(command="python3 << 'EOF'\nprint('Hello')\nEOF")
For multi-line code, build the command string:
code = """
import json
data = {"status": "ok", "count": 42}
print(json.dumps(data))
"""
run_shell(command=f"python3 << 'EOF'\n{code}\nEOF")
Why This Works
run_shellexecutes commands directly in the shell environment, bypassing sandbox issues- Heredoc syntax (
<< 'EOF') allows clean multi-line Python code without complex escaping - Single quotes around EOF prevent unwanted shell variable expansion
- More reliable for simple to moderate Python execution tasks
Guidelines
- Always use single quotes around EOF (
'EOF') to prevent variable expansion - Test with a simple print statement first to verify Python is available
- For longer scripts, consider writing to a
.pyfile first, then executing:run_shell(command="python3 /path/to/script.py") - Capture stdout from run_shell to get Python output
- Handle errors by checking run_shell's stderr output
Example: Complete Workflow
# Step 1: Try execute_code_sandbox
try:
result = execute_code_sandbox(code="print(2+2)")
except Exception as e:
# Step 2: Fallback to run_shell with heredoc
result = run_shell(command="python3 << 'EOF'\nprint(2+2)\nEOF")
# Parse stdout to get the output
output = result.stdout.strip()
Troubleshooting
| Issue | Solution |
|---|---|
| Python not found | Use which python3 to verify installation |
| Heredoc not working | Ensure single quotes around EOF delimiter |
| Complex imports fail | Install required packages or write to .py file |
| Output not captured | Check run_shell stdout, not return value |
よくある質問
heredocとは何ですか?
先にファイルに保存せずに、数行のコードをプログラムに渡す方法です。
長いスクリプトにも使うべきですか?
スキルは、長いスクリプトはまずファイルに保存してから、そのファイルを実行するよう勧めています。
EOFを単一引用符で囲むのはなぜですか?
単一引用符で囲むと、シェルがコードの中のドル記号などの記号を変えるのを防げるからです。
詳細
作者による元の説明
Fallback method for executing Python when execute_code_sandbox fails with unknown errors
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12958
- ライセンス
- 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のイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。