sandbox-fallback-python-e5d7ae
यह क्या करती है
यह स्किल बताती है कि जब सैंडबॉक्स शुरू या कनेक्ट न हो, तब AI एजेंट शेल से Python कोड कैसे चलाए। यह उन लोगों के लिए है जो reportlab या pandas जैसी लाइब्रेरी इस्तेमाल करते हैं।
कब इस्तेमाल करें
- ✓जब सैंडबॉक्स इनिशियलाइज़ेशन, स्टार्टअप या कनेक्शन एरर दिखाए।
- ✓जब एक छोटी स्क्रिप्ट को तुरंत शेल में चलाना हो।
- ✓जब लंबी स्क्रिप्ट को फ़ाइल में सहेजकर ज़्यादा समय सीमा के साथ चलाना हो।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python-e5d7ae/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“सैंडबॉक्स शुरू नहीं हो रहा। शेल में स्क्रिप्ट चलाकर reportlab से मेरा PDF इनवॉइस बनाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
छोटे कोड के लिए एजेंट शेल कमांड के अंदर heredoc इस्तेमाल करता है। लंबे कोड के लिए वह स्क्रिप्ट को एक अस्थायी फ़ाइल में लिखता है और चलाता है, ज़रूरत हो तो ज़्यादा समय के साथ।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Python Sandbox Fallback Pattern
When to Use
Use this pattern when execute_code_sandbox fails with e2b/sandbox initialization errors, especially when running Python code that requires external libraries like reportlab, pandas, numpy, etc.
Common Failure Indicators
Detect these error patterns to trigger the fallback:
e2binitialization errorssandboxcreation/creation timeout failurescontainerstartup errors- Connection/refusal errors from sandbox service
The Fallback Pattern
Basic Heredoc Approach
For short scripts, use a Python heredoc directly in run_shell:
run_shell(
command="""python3 << 'EOF'
import sys
print(f"Python version: {sys.version}")
# Your code here
EOF
""",
timeout=60
)
File-Based Approach for Complex Scripts
For longer scripts or when you need to preserve state across multiple executions:
# Step 1: Write the script to a temporary file
script_content = '''
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
import os
# Your code here
'''
run_shell(command=f"cat > /tmp/script.py << 'SCRIPT_EOF'\n{script_content}\nSCRIPT_EOF")
# Step 2: Execute the script
result = run_shell(command="python3 /tmp/script.py", timeout=120)
Key Considerations
Timeouts
run_shelltypically needs longer timeouts thanexecute_code_sandbox- Use
timeout=60for simple scripts - Use
timeout=120or higher for library-heavy operations (PDF generation, data processing)
Library Availability
- Verify required libraries are installed in the shell environment
- Install missing libraries first if needed:
run_shell(command="pip install reportlab", timeout=60)
Error Handling
- Capture and inspect
run_shelloutput for Python errors - Check stderr for import failures or runtime exceptions
Working Directory
- Files created via
run_shellare in the current working directory by default - Use absolute paths or
os.getcwd()to reference files reliably
Example: PDF Generation with reportlab
# FALLBACK VERSION (when execute_code_sandbox fails):
pdf_code = """
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def create_memo(filename):
c = canvas.Canvas(filename, pagesize=letter)
c.drawString(1*inch, 10*inch, "Legal Memorandum")
c.save()
print(f"Created {filename}")
create_memo('/workspace/output.pdf')
"""
# Write script to file
run_shell(command=f"cat > /tmp/create_pdf.py << 'PYEOF'\n{pdf_code}\nPYEOF")
# Execute and verify
run_shell(command="python3 /tmp/create_pdf.py", timeout=120)
# Verify output exists
run_shell(command="ls -la /workspace/output.pdf", timeout=30)
Comparison Table
| Aspect | execute_code_sandbox | run_shell (fallback) |
|---|---|---|
| Isolation | High (containerized) | Low (host environment) |
| Reliability | Can fail with e2b errors | More reliable |
| Library Access | Pre-configured sandbox | Depends on host |
| Timeout | Default 30s | Configurable |
| File Access | ARTIFACT_PATH convention | Direct filesystem |
Migration Checklist
When switching from execute_code_sandbox to run_shell:
- Increase timeout values (typically 2-4x)
- Convert ARTIFACT_PATH references to actual file paths
- Add explicit file verification steps after execution
- Handle potential library import errors
- Test script execution in shell environment first
अक्सर पूछे जाने वाले सवाल
लंबी समय सीमा क्यों?
स्किल बताती है कि शेल रन को आमतौर पर सैंडबॉक्स रन से ज़्यादा समय चाहिए।
अस्थायी फ़ाइल कहाँ रखी जाती है?
स्किल का उदाहरण उसे temp फ़ोल्डर में लिखता है, हालाँकि एजेंट कोई और जगह चुन सकता है।
कौन सी लाइब्रेरी का ज़िक्र है?
यह reportlab, pandas और numpy को उन लाइब्रेरी के उदाहरण बताती है जिनकी कोड को ज़रूरत हो सकती है।
जानकारी
लेखक का मूल विवरण
Fallback to run_shell with Python heredoc when execute_code_sandbox fails
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12991
- लाइसेंस
- 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 खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।