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

sandbox-execution-fallback-238489

ما الذي تفعله

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

متى تستخدمها

  • ✓عندما تفشل بيئة التنفيذ المعزولة في إنشاء ملف PDF أو Word أو Excel.
  • ✓عندما تحتاج المهمة إلى مكتبة Python لا توفرها بيئة التنفيذ المعزولة.
  • ✓عندما تريد تحكمًا أكبر في البيئة التي يعمل فيها البرنامج.

رابط المهارة

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

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

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

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

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

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

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

“أنشئ لي ملف PDF من ملاحظاتي باستخدام مكتبة reportlab. فشلت بيئة التنفيذ المعزولة، فاكتب ملف برنامج وشغّله.”

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

كيف تعمل

يستخدم الوكيل أداة كتابة الملفات لحفظ البرنامج، ثم يشغّله بالأمر python3 عبر الطرفية. بعدها يتحقق من أن البرنامج انتهى وأن الملفات المتوقعة قد أُنشئت.

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

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

Sandbox Execution Fallback

This skill provides a reliable fallback pattern when execute_code_sandbox fails for code execution tasks (especially PDF generation, complex file operations, or library-dependent tasks).

When to Use

Use this fallback pattern when:

  • execute_code_sandbox returns errors or fails to produce expected output
  • The task requires specific Python libraries not available in the sandbox
  • File I/O operations (especially PDF, docx, xlsx) fail in the sandbox environment
  • You need more control over the execution environment

Step-by-Step Instructions

Step 1: Write the Python Script to a File

Instead of executing code directly in the sandbox, use write_file to create a standalone Python script:

Use write_file to create a script (e.g., script.py) with your complete Python code.

Step 2: Execute the Script Directly

Run the script using run_shell with Python:

Use run_shell with command: python3 script.py

Step 3: Verify Output

Check that the script executed successfully and produced the expected files or output.

Example Pattern

Instead of this (sandbox execution):

execute_code_sandbox with code using libraries like reportlab, fpdf, etc.

Do this (fallback pattern):

# Step 1: Create the script
write_file:
  path: generate_pdf.py
  content: |
    from reportlab.lib.pagesizes import letter
    from reportlab.pdfgen import canvas
    
    def create_pdf(filename):
        c = canvas.Canvas(filename, pagesize=letter)
        c.drawString(100, 750, "Hello World")
        c.save()
    
    create_pdf("output.pdf")

# Step 2: Execute directly
run_shell:
  command: python3 generate_pdf.py

Best Practices

  1. Include all dependencies in the script - Make the script self-contained
  2. Add error handling - Include try/except blocks to catch and report errors
  3. Use absolute or clear relative paths - Ensure file paths work in the execution context
  4. Verify prerequisites - Check that required Python packages are available
  5. Clean up temporary files - Remove intermediate scripts after successful execution if needed

Troubleshooting

If run_shell also fails:

  • Check if Python 3 is available: run_shell command: python3 --version
  • Install missing packages: run_shell command: pip3 install package_name
  • Check file permissions and paths
  • Review error output from the shell execution for specific issues

Why This Works

This pattern bypasses sandbox limitations by:

  • Running code in the actual execution environment with full library access
  • Avoiding sandbox timeout or resource constraints
  • Enabling direct file system access for I/O operations
  • Providing better error messages from the native Python interpreter

Self-Assessment

This skill captures a genuinely reusable pattern that:

  • Is generalizable beyond just PDF generation to any execute_code_sandbox failure
  • Provides clear, actionable steps
  • Includes example code and troubleshooting guidance
  • Would benefit future executions facing similar sandbox limitations
الأسئلة الشائعة

ما أنواع الملفات التي تغطيها؟

تذكر المهارة ملفات PDF وWord وExcel بوصفها أنواع المخرجات التي تفشل كثيرًا في بيئة التنفيذ المعزولة.

لماذا يكتب الوكيل ملفًا بدل تنفيذ الكود مباشرة؟

الملف المحفوظ يمنح الطرفية ملفًا واضحًا لتشغيله، ويسهّل مراجعة العمل.

هل يتأكد الوكيل من المخرجات؟

نعم، الخطوة الأخيرة هي التحقق من إنشاء الملفات المتوقعة.

التفاصيل

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

Fallback pattern for when execute_code_sandbox fails - write script to file and execute directly with run_shell

repo: HKUDS/AgentPilot

الشعبية

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

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

0

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

التعليقات

  • …

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

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