fallback-python-execution
できること
このスキルは、サンドボックスやヘルパーエージェントがPythonを実行できないときの予備の方法です。データファイルや文書ファイルを作るためにPythonが必要な人向けです。
使う場面
- ✓サンドボックスが、原因不明のエラーを返すか、繰り返し失敗するとき。
- ✓スプレッドシート、文書、データファイルを作るためにPythonが必要なとき。
- ✓ヘルパーエージェントが、Pythonのコードを正しく実行できなかったとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-python-execution/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“ヘルパーがスプレッドシートを作るためのPythonスクリプトを実行できません。スクリプトをファイルに保存して、直接実行してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、完全なPythonのコードを.pyファイルに書き、シェルコマンドで実行し、想定したファイルが現れたかを確認して、必要ならスクリプトを後で削除します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Fallback Python Execution Pattern
When to Use
Use this pattern when:
execute_code_sandboxreturns unknown errors or fails repeatedlyshell_agentcannot successfully execute Python code- You need to create files (spreadsheets, documents, data files) via Python
- Direct delegated approaches prove unreliable in the current environment
Core Technique
Instead of delegating Python execution to agents, use this two-step inline approach:
- Write Python code to a
.pyfile usingwrite_file - Execute the file using
run_shellwithpython <script.py>
Step-by-Step Instructions
Step 1: Write Python Code to File
Use write_file to create a Python script with all necessary code inline:
write_file
path: /path/to/script.py
content: |
import pandas as pd
# Your complete Python code here
df = pd.DataFrame({...})
df.to_excel('output.xlsx', index=False)
Step 2: Execute via run_shell
Run the script directly:
run_shell
command: python /path/to/script.py
Step 3: Verify and Clean Up
- Check the output for success/errors
- Verify the expected files were created
- Optionally remove the temporary script if no longer needed
Why This Works
This approach is more reliable because:
- Avoids agent interpretation layers that can introduce errors
- Provides direct control over execution environment
- Gives clear error output for debugging
- Bypasses sandbox delegation issues
Example: Excel File Creation
# Step 1: Write the script
write_file:
path: create_report.py
content: |
import pandas as pd
from openpyxl import Workbook
# Create data
data = {'Column1': [1, 2, 3], 'Column2': ['A', 'B', 'C']}
df = pd.DataFrame(data)
# Save to Excel
df.to_excel('report.xlsx', index=False)
print('Excel file created successfully')
# Step 2: Execute
run_shell:
command: python create_report.py
Tips
- Include error handling in your Python code for better debugging
- Use absolute paths when possible to avoid working directory issues
- Add print statements to track execution progress
- Keep scripts self-contained with all imports at the top
- For complex tasks, break into multiple scripts if needed
Troubleshooting
| Issue | Solution |
|---|---|
| Module not found | Add pip install commands before python command |
| Permission errors | Check file paths are writable |
| Script not found | Use absolute path or cd to directory first |
| Output not created | Check for Python errors in run_shell output |
よくある質問
なぜヘルパーエージェントを避けるのですか?
この方法は、エラーを生みうる余分な解釈の層を避けられるからだと、ガイドは述べています。
スクリプトは後で削除できますか?
はい。一時的なスクリプトの削除は、任意の最後のステップです。
最後に何を確認すべきですか?
成功かエラーかの出力と、想定したファイルが作られたかです。
詳細
作者による元の説明
Reliable Python execution workflow when execute_code_sandbox or shell_agent fail
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12882
- ライセンス
- 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のイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。