Skillpedia
برمجة عامة7.8k · #12990

sandbox-fallback-execution

ما الذي تفعله

تعرض هذه المهارة لوكيل الذكاء الاصطناعي حلًا بديلًا بسيطًا لكود Python عندما تفشل بيئة التنفيذ المعزولة أو تنتهي مهلتها. وهي مناسبة لمن يحتاج إلى إنهاء مهمة Python قصيرة دون بيئة التنفيذ المعزولة.

متى تستخدمها

  • ✓عندما تفشل بيئة التنفيذ المعزولة بأخطاء غير معروفة أو تنتهي مهلتها.
  • ✓عندما تفشل بيئة التنفيذ المعزولة أكثر من مرتين في المهمة نفسها.
  • ✓عندما يلزم تثبيت حزمة Python قبل أن يعمل الكود.

رابط المهارة

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

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-execution/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أعطتني بيئة التنفيذ المعزولة خطأ غير معروف في برنامجي. ثبّت pandas إن لزم الأمر، وشغّل الكود عبر الطرفية.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يثبّت الوكيل الحزم اللازمة بالأمر pip، ثم يشغّل كود Python عبر الطرفية باستخدام heredoc. ويفحص المخرجات بحثًا عن رسائل النجاح أو الأخطاء قبل أن يكمل.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Sandbox Fallback Execution

When to Use This Skill

Use this pattern when execute_code_sandbox fails with unknown errors, timeouts, or persistent execution failures. This fallback bypasses sandbox restrictions by using run_shell with a Python heredoc script.

Pattern Overview

execute_code_sandbox fails → run_shell with pip install → Python heredoc execution

Step-by-Step Instructions

Step 1: Detect Sandbox Failure

Monitor for these failure indicators from execute_code_sandbox:

  • Unknown or unexplained errors
  • Repeated execution failures (>2 attempts)
  • Timeout errors
  • Environment/package availability issues

Step 2: Install Required Dependencies (If Needed)

Use run_shell to install any required Python packages:

pip install <package_name>

For multiple packages:

pip install package1 package2 package3

Step 3: Execute Python via Heredoc

Run Python code using a heredoc script with run_shell:

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

Key heredoc syntax notes:

  • Use << 'EOF' (quoted) to prevent shell variable expansion
  • Use << EOF (unquoted) if you need shell variable interpolation
  • Close with EOF on its own line

Step 4: Verify and Iterate

  • Check stdout/stderr for success indicators
  • If errors persist, inspect output and adjust the script
  • Capture any generated artifacts (files, outputs) for verification

Complete Example

Scenario: Need to create a Word document but execute_code_sandbox keeps failing.

# Step 1: Install required package
pip install python-docx

# Step 2: Execute Python script via heredoc
python3 << 'EOF'
from docx import Document

doc = Document()
doc.add_heading('Proposal Document', 0)
doc.add_paragraph('This is the proposal content.')
doc.save('proposal.docx')
print("Document created successfully")
EOF

Best Practices

  1. Quote the heredoc delimiter ('EOF') to avoid unintended shell expansion of Python code
  2. Install packages first before running the script to ensure availability
  3. Print status messages in your script for easier debugging
  4. Save outputs to files when possible for verification
  5. Keep scripts focused - break complex tasks into multiple heredoc executions if needed

Troubleshooting

Issue Solution
pip not found Try pip3 or python3 -m pip install
Script hangs Add timeout to run_shell command
Permission errors Check file paths are writable
Import errors Verify package was installed successfully

Related Tools

  • run_shell: Execute shell commands directly
  • execute_code_sandbox: Primary Python execution tool (try first)
  • shell_agent: For more complex multi-step shell tasks
الأسئلة الشائعة

ما الفرق بين علامة الإنهاء المقتبسة وغير المقتبسة؟

العلامة المقتبسة تمنع الطرفية من تعديل المتغيرات، أما غير المقتبسة فتسمح لها بملء قيمها.

هل يثبّت الوكيل الحزم؟

نعم، إذا احتاج الكود إلى حزمة، تقول المهارة إن عليه تثبيتها بالأمر pip أولًا.

ماذا لو بقيت الأخطاء؟

تقول المهارة إن على الوكيل قراءة المخرجات، وتعديل الكود، ثم تشغيله مرة أخرى.

التفاصيل

الوصف الأصلي من المؤلف

Fallback workflow for executing Python code when execute_code_sandbox fails

repo: HKUDS/AgentPilot

الشعبية

نجوم GitHub
7.8k
الترتيب
#12990
الترخيص
MIT
آخر تحديث
1‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة