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

sandbox-execution-fallback

ما الذي تفعله

توضح هذه المهارة لوكيل الذكاء الاصطناعي كيف يستعيد تشغيلًا فاشلًا بحفظ الكود في ملف بامتداد py وتشغيله. وهي مناسبة لمن تنتهي مهلة مهام الجداول أو البيانات لديه داخل بيئة التنفيذ المعزولة.

متى تستخدمها

  • ✓عندما تنتهي مهلة بيئة التنفيذ المعزولة في مهمة جداول أو بيانات.
  • ✓عندما تحتاج المهمة إلى مكتبات خارجية مثل pandas أو openpyxl.
  • ✓عندما تستمر عملية حسابية طويلة في تجاوز الحد الزمني لبيئة التنفيذ المعزولة.

رابط المهارة

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

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

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

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

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

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

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

“مهمة pandas الخاصة بي تنتهي مهلتها في بيئة التنفيذ المعزولة. احفظ الكود في ملف وشغّله في الطرفية بمهلة أطول.”

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

كيف تعمل

يأخذ الوكيل الكود الذي فشل، ويكتبه في ملف py باسم واضح، ويشغّله بمفسّر Python المثبّت في النظام، ثم يتحقق من وجود الملفات والنتائج المتوقعة.

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

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

Sandbox Execution Fallback

When to Use

Apply this pattern when execute_code_sandbox fails or times out, particularly for:

  • Spreadsheet generation (pandas, openpyxl, xlsxwriter)
  • Complex data processing with file I/O
  • Tasks requiring external library imports
  • Long-running computations that hit timeout limits

Recovery Procedure

Step 1: Capture the Python Code

Extract or reconstruct the Python code that failed in execute_code_sandbox.

Step 2: Write Code to File

Use write_file to save the script with a .py extension:

write_file(
    path="script_name.py",
    content="""
import pandas as pd
# Your implementation here
"""
)

Step 3: Execute via run_shell

Run the script using the system Python interpreter:

run_shell(command="python3 script_name.py")

Step 4: Verify Output

Confirm the results match expected outputs (files created, data processed correctly, etc.).

Complete Example

# Failed: execute_code_sandbox with pandas Excel generation

# Recovery - Step 1 & 2: Write script to file
write_file(
    path="generate_pnl_report.py",
    content="""
import pandas as pd
from openpyxl import Workbook

# Create sample data
data = {
    'Category': ['Revenue', 'Expenses', 'Tax'],
    'Amount': [10000, 3000, 500]
}
df = pd.DataFrame(data)

# Write to Excel
df.to_excel('pnl_report.xlsx', index=False)
print('Report generated: pnl_report.xlsx')
"""
)

# Step 3: Execute via shell
run_shell(command="python3 generate_pnl_report.py")

# Step 4: Verify file was created
run_shell(command="ls -la pnl_report.xlsx")

Why This Works

Aspect execute_code_sandbox run_shell + write_file
Environment Sandboxed, limited Full system Python
File I/O Restricted Full access
Timeout Strict limits More flexible
Library Support May be limited System-installed packages
Result Identical output Identical output

Best Practices

  1. Use descriptive filenames - e.g., generate_report.py, process_data.py
  2. Add error handling - Include try/except blocks in your script
  3. Print progress - Use print statements for debugging
  4. Clean up - Remove temporary scripts after successful execution if needed
  5. Verify results - Always confirm outputs before proceeding

Common Use Cases

  • Excel/CSV report generation
  • Data transformation pipelines
  • Batch file processing
  • API data aggregation
  • Chart and visualization creation

Troubleshooting

If run_shell also fails:

  1. Check Python is available: run_shell(command="python3 --version")
  2. Install missing packages: run_shell(command="pip3 install pandas openpyxl")
  3. Check file permissions and paths
  4. Review stderr output for specific errors
الأسئلة الشائعة

هل يستطيع الوكيل استعادة الكود إن لم يكن محفوظًا؟

تقول المهارة إن عليه إعادة بناء الكود من المحاولة الفاشلة إذا لم يكن قد حُفظ.

ما أمر Python المستخدم؟

تشغّل المهارة البرنامج بالأمر python3 من الطرفية.

كيف يتحقق الوكيل من النجاح؟

يتأكد من إنشاء الملفات ومعالجة البيانات كما هو متوقع.

التفاصيل

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

Recover from execute_code_sandbox failures by writing Python scripts to files and executing via run_shell

repo: HKUDS/AgentPilot

الشعبية

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

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

0

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

التعليقات

  • …

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

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