execute-code-fallback
यह क्या करती है
यह स्किल AI को बताती है कि जब कोड सैंडबॉक्स से कनेक्ट न हो या टाइम आउट हो, तो शेल में Python चलाने पर स्विच करे। यह उन लोगों के लिए है जिनके AI टास्क को सैंडबॉक्स सेवा बंद होने पर भी कोड चलना चाहिए।
कब इस्तेमाल करें
- ✓जब कोड सैंडबॉक्स बताए कि वह उपलब्ध नहीं है या उससे कनेक्ट नहीं हो पा रहा।
- ✓जब सैंडबॉक्स लगातार दो या अधिक बार टाइम आउट हो या विफल हो।
- ✓जब कोड चलने से पहले कुछ अतिरिक्त पैकेज इंस्टॉल करने पड़ें।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/execute-code-fallback/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“कोड सैंडबॉक्स अभी बंद है। कृपया Python स्क्रिप्ट शेल में चलाइए, और ज़रूरी पैकेज पहले इंस्टॉल कर दीजिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI ज़रूरी पैकेज pip से इंस्टॉल करता है, फिर Python कोड शेल कमांड से चलाता है, और लंबी स्क्रिप्ट के लिए heredoc इस्तेमाल करता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Execute Code Fallback Pattern
When execute_code_sandbox fails due to e2b unavailability, immediately fall back to run_shell with embedded Python code. This ensures task continuity when the sandbox service is down.
When to Apply
Use this pattern when you observe:
execute_code_sandboxreturns errors mentioning "e2b", "sandbox unavailable", or connection timeouts- Repeated sandbox execution failures (2+ attempts)
- Error messages indicating the code execution environment is unreachable
Fallback Procedure
Step 1: Detect the Failure
Identify that execute_code_sandbox has failed. Common error indicators:
- "e2b service unavailable"
- "Sandbox connection failed"
- "Execution environment not reachable"
- Timeout errors during code execution
Step 2: Switch to run_shell with Embedded Python
Instead of:
execute_code_sandbox(code="...")
Use:
run_shell(command="python3 -c '...your Python code...'")
Step 3: Install Dependencies First (If Needed)
If your Python code requires external packages, install them first:
run_shell(command="pip install pandas requests matplotlib")
Then execute your main code:
run_shell(command="python3 << 'EOF'
import pandas as pd
import requests
# Your code here
print("Success")
EOF
")
Step 4: Use Heredoc for Multi-line Code
For complex Python scripts, use heredoc syntax for cleaner code:
run_shell(command="python3 << 'PYTHON_SCRIPT'
import json
import os
# Complex logic here
data = {'key': 'value'}
with open('output.json', 'w') as f:
json.dump(data, f)
print('File created successfully')
PYTHON_SCRIPT
")
Complete Example
Scenario: You need to process a CSV file and generate a report.
Original approach (sandbox):
execute_code_sandbox(code="""
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
""")
Fallback approach (run_shell):
# First install dependencies if needed
run_shell(command="pip install pandas --quiet")
# Then execute the code
run_shell(command="python3 << 'EOF'
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
EOF
")
Important Considerations
State Persistence: Unlike
execute_code_sandbox,run_shellexecutions may not share state between calls. Save intermediate results to files if needed.Working Directory: Ensure you're operating in the correct directory. Use
pwdto verify or includecd /path/to/workdirin your commands.Python Version: Use
python3explicitly to avoid ambiguity. Verify withpython3 --versionif needed.Error Handling: Check the stdout/stderr from
run_shellto confirm success. Failed Python scripts will return non-zero exit codes.Security: Be cautious when embedding user-provided data into shell commands. Escape appropriately or use file-based input.
Performance: For large computations,
run_shellmay be slower than sandbox. Consider breaking into smaller steps if timeouts occur.
Quick Reference
| Task | Sandbox Approach | Fallback Approach |
|---|---|---|
| Simple calculation | execute_code_sandbox(code="print(2+2)") |
run_shell(command="python3 -c 'print(2+2)'") |
| Install + run | execute_code_sandbox(code="import pkg; ...") |
run_shell(command="pip install pkg && python3 -c '...'") |
| Multi-line script | execute_code_sandbox(code="...") |
run_shell(command="python3 << 'EOF'...EOF") |
| File I/O | execute_code_sandbox(code="...") |
run_shell(command="python3 << 'EOF'...EOF") |
Recovery Checklist
- Confirm
execute_code_sandboxfailure (not a code bug) - Switch to
run_shellimmediately - Install required packages with
pip install - Use heredoc for multi-line Python
- Verify output and handle errors
- Save intermediate results to files if multi-step
अक्सर पूछे जाने वाले सवाल
कौन सी एरर स्विच को ट्रिगर करती हैं?
गाइड में सैंडबॉक्स उपलब्ध न होने, कनेक्शन टाइम आउट और पहुँच से बाहर एक्ज़िक्यूशन वातावरण के संदेशों का ज़िक्र है।
पैकेज कैसे जोड़े जाते हैं?
गाइड मुख्य कोड चलाने से पहले उन्हें pip से इंस्टॉल करती है।
heredoc क्यों इस्तेमाल करें?
इससे एक शेल कमांड में पूरी बहु-पंक्ति स्क्रिप्ट चल सकती है।
जानकारी
लेखक का मूल विवरण
Fallback from execute_code_sandbox to run_shell when e2b sandbox is unavailable
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12878
- लाइसेंस
- 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 खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।