मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग7.8k · #12992

sandbox-fallback-python

यह क्या करती है

यह स्किल AI एजेंट को तब शेल से Python चलाने का मार्गदर्शन देती है जब सैंडबॉक्स तक पहुँच न हो। यह उन लोगों के लिए है जिनके Python काम पैकेज और फ़ाइल आउटपुट पर निर्भर हैं।

कब इस्तेमाल करें

  • ✓जब सैंडबॉक्स बताए कि वह उपलब्ध नहीं है या कनेक्शन विफल हुआ।
  • ✓जब Python स्क्रिप्ट को चलने से पहले कुछ पैकेज इंस्टॉल करने पड़ें।
  • ✓जब स्क्रिप्ट को वर्किंग फ़ोल्डर में फ़ाइलें पढ़नी या लिखनी हों।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“सैंडबॉक्स उपलब्ध नहीं है। मेरी स्क्रिप्ट के लिए ज़रूरी पैकेज इंस्टॉल कीजिए, फिर उसे चलाकर आउटपुट मेरे वर्कस्पेस में सहेजिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट pip से पैकेज इंस्टॉल करता है, फिर heredoc से Python कोड शेल में चलाता है। फ़ाइलों के लिए वह स्पष्ट पाथ इस्तेमाल करता है और यह पुष्टि करने के लिए फ़ोल्डर की सूची देखता है कि आउटपुट सहेजा गया।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Sandbox Fallback: Python via run_shell

When to Use This Skill

Apply this skill when execute_code_sandbox fails with errors indicating:

  • e2b service unavailability
  • Sandbox timeout or connection issues
  • Code execution environment not accessible

This fallback allows you to execute Python code directly via shell, bypassing the sandbox infrastructure.

Fallback Procedure

Step 1: Detect Sandbox Failure

Identify fallback necessity from error messages like:

  • "e2b unavailable"
  • "sandbox connection failed"
  • "execution environment error"
  • Timeout errors during code execution

Step 2: Switch to run_shell with Embedded Python

Instead of execute_code_sandbox, use run_shell with a Python heredoc or inline script:

python3 << 'EOF'
# Your Python code here
print("Hello from fallback execution")
EOF

Step 3: Install Dependencies First

If your Python code requires packages not guaranteed to be installed:

pip install package_name package_name2 && python3 << 'EOF'
# Your Python code here
import package_name
print("Code with dependencies executed")
EOF

Step 4: Handle File I/O

For scripts that need to read/write files:

  • Use absolute or explicit relative paths
  • Files persist in the workspace directory
  • List directory contents with ls to verify file operations
python3 << 'EOF'
import os
# Write output to file
with open("output.txt", "w") as f:
    f.write("Results here")
# Verify
print(f"Working directory: {os.getcwd()}")
EOF

Code Examples

Simple Calculation

python3 << 'EOF'
result = sum(range(100))
print(f"Sum: {result}")
EOF

With Package Installation

pip install requests -q && python3 << 'EOF'
import requests
response = requests.get("https://api.example.com/data")
print(response.json())
EOF

With JSON Processing

python3 << 'EOF'
import json

data = {"key": "value", "count": 42}
output = json.dumps(data, indent=2)
print(output)

# Save to file
with open("data.json", "w") as f:
    f.write(output)
EOF

Best Practices

  1. Use heredoc syntax - << 'EOF' prevents variable expansion issues
  2. Install quietly - Use pip install -q to reduce output noise
  3. Error handling - Add try/except blocks in Python code for robustness
  4. Verify execution - Check stdout/stderr from run_shell to confirm success
  5. Keep code compact - Long scripts are harder to debug in shell context

Caveats

  • No persistent state between run_shell calls (unlike execute_code_sandbox)
  • Longer execution time for complex scripts due to Python interpreter startup
  • Limited debugging - Cannot easily inspect variables between statements
  • Output size limits - Very large outputs may be truncated

When NOT to Use This Fallback

  • If the task specifically requires sandbox isolation for security
  • If you need persistent state across multiple code executions
  • If the code execution is extremely long-running (consider backgrounding)
अक्सर पूछे जाने वाले सवाल

एजेंट आउटपुट कैसे जाँचता है?

वह शेल के संदेश पढ़ता है और नई फ़ाइलें देखने के लिए फ़ोल्डर की सूची बनाता है।

स्पष्ट पाथ क्यों इस्तेमाल करें?

स्पष्ट पाथ पक्का करते हैं कि फ़ाइलें उसी वर्कस्पेस फ़ोल्डर में सहेजी जाएँ जिसकी आप उम्मीद करते हैं।

क्या बिना कुछ इंस्टॉल किए यह काम करता है?

अगर पैकेज पहले से मौजूद हों, तो इंस्टॉल चरण छोड़ा जा सकता है।

जानकारी

लेखक का मूल विवरण

Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#12992
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills