python-execution-fallback-9d4989
यह क्या करती है
यह स्किल AI एजेंट को तब सरल Python कोड चलाने का बैकअप तरीका देती है जब उसका सैंडबॉक्स टूल टूट जाए। यह उन लोगों के लिए है जिनका AI टूल छोटे Python कोड पर भी अज्ञात एरर देता है।
कब इस्तेमाल करें
- ✓जब कोड सैंडबॉक्स एक सरल print स्टेटमेंट पर भी अज्ञात एरर लौटाए।
- ✓जब आपको एक जल्दी का Python हिसाब चाहिए और सैंडबॉक्स जवाब न दे रहा हो।
- ✓जब आप जाँचना चाहें कि AI की मशीन पर Python चलता भी है या नहीं।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-execution-fallback-9d4989/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“कोड सैंडबॉक्स बार-बार विफल हो रहा है। इस Python हिसाब को किसी और तरीके से चलाइए और नतीजा दिखाइए।”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।