fallback-script-execution
ما الذي تفعله
هذه المهارة طريقة متكررة لتشغيل سكربتات Python على خطوتين، تعطي رسائل خطأ أوضح. وهي مناسبة لمن يصحح شيفرة لا تعمل عبر الأدوات المعتادة.
متى تستخدمها
- ✓عندما يفشل وكيل مساعد مرارًا برسائل غير واضحة أثناء تشغيل الشيفرة.
- ✓عندما تنتهي مهلة بيئة الشيفرة أو تفشل على الشيفرة نفسها.
- ✓عندما أريد إصلاح السكربت وإعادة تشغيله دون إعادة كتابته كل مرة.
رابط المهارة
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-script-execution/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“المساعد يفشل باستمرار عند تشغيل سكربتي. من فضلك احفظ السكربت كملف وشغّله حتى أرى الخطأ كاملًا.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يكتب الذكاء الاصطناعي سكربتًا مستقلًا فيه معالجة للأخطاء إلى ملف، ثم يشغّله بأمر في الطرفية حتى تظهر كل تفاصيل الخطأ وناتج التشغيل.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Fallback Script Execution with write_file + run_shell
When to Use This Skill
Use this pattern when:
shell_agentfails repeatedly with unclear error messagesexecute_code_sandboxconsistently errors or times out- You need better visibility into what's happening during execution
- Debugging inline code or delegated agents proves difficult
Core Pattern
Instead of delegating execution to an agent or running inline code, use this two-step approach:
- Write script to file using
write_file - Execute script using
run_shellwithpython script.py
This provides:
- Clearer error messages (full stack traces visible in run_shell output)
- Easier debugging (script persists for inspection)
- Better control over execution environment
- Ability to modify and re-run without rewriting code
Step-by-Step Instructions
Step 1: Write the Script File
Use write_file to create a self-contained Python script:
write_file with:
path: "path/to/script_name.py"
content: |
#!/usr/bin/env python3
# Your complete script here
# Include imports, logic, and error handling
Best Practices:
- Include descriptive comments
- Add try/except blocks for error handling
- Print intermediate results for debugging
- Use absolute or clear relative paths
Step 2: Execute the Script
Use run_shell to execute the script:
run_shell with:
command: "python path/to/script_name.py"
Best Practices:
- Capture and examine full output
- If errors occur, the script file is still available for inspection
- You can re-run with modifications without starting over
Example: Data Processing Task
❌ Problematic Approach (shell_agent fails repeatedly)
shell_agent with:
task: "Load Excel file, calculate correlations, save results"
Result: Agent struggles with path handling, unclear errors
✅ Recommended Approach (write_file + run_shell)
# Step 1: Write script
write_file with:
path: "correlation_analysis.py"
content: |
import pandas as pd
import sys
try:
# Load data
df = pd.read_excel('data.xlsx', sheet_name='Returns')
print(f"Loaded {len(df)} rows")
# Calculate correlation
corr = df.corr()
print(f"Correlation matrix shape: {corr.shape}")
# Save results
with pd.ExcelWriter('output.xlsx') as writer:
df.to_excel(writer, sheet_name='Returns')
corr.to_excel(writer, sheet_name='Correlation')
print("SUCCESS: output.xlsx created")
except Exception as e:
print(f"ERROR: {type(e).__name__}: {e}", file=sys.stderr)
sys.exit(1)
# Step 2: Execute script
run_shell with:
command: "python correlation_analysis.py"
Debugging Tips
- Add print statements at key points to trace execution
- Check file paths - use
run_shellwithls -la path/to verify files exist - Inspect errors - run_shell output shows full Python stack traces
- Modify and re-run - edit the script file and execute again without rewriting
When to Escalate
If this pattern also fails:
- Verify Python is available:
run_shellwithwhich pythonorpython --version - Check file permissions:
run_shellwithls -la script.py - Try explicit Python path:
run_shellwith/usr/bin/python script.py - Consider task complexity - may need to break into smaller scripts
الأسئلة الشائعة
لماذا الملف أفضل للتصحيح؟
يبقى السكربت على القرص، فيمكن فحصه وإعادة تشغيله بعد التعديل.
ما الذي يجعل ناتج الخطأ أوضح؟
تظهر تتبعات الخطأ الكاملة في ناتج الطرفية بدل أن تكون مخفية.
ما الذي يجب أن يتضمنه السكربت؟
عبارات الاستيراد والمنطق الرئيسي وكتل try وexcept ورسائل تقدم مطبوعة.
التفاصيل
الوصف الأصلي من المؤلف
Two-step script execution workflow for debugging when shell_agent and execute_code_sandbox consistently fail
repo: HKUDS/AgentPilot
الشعبية
- نجوم GitHub
- 7.8k
- الترتيب
- #12884
- الترخيص
- MIT
- آخر تحديث
- 1/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
agentpilot
7.8kيساعد وكيلك على تحسين مشروع خطوة بخطوة، بتجهيز مهمة وتشغيل حلقة AgentPilot التي تقترح التغييرات وتختبرها وتقيّمها.
openspace
7.8kيساعد وكيلك على إعداد OpenSpace، وهو أداة تخزن مهارات الوكلاء وتسترجعها، وربطه بتطبيق الذكاء الاصطناعي عبر MCP.
rsi-arena
7.8kيساعد وكيلك على إعداد اختبارات معيارية مثل AIME وTerminal-Bench وتشغيلها، لمقارنة طرق التحسين المختلفة.
experiment-guide
7.8kيساعد وكيلك على تخطيط تجارب صغيرة وقراءة نتائجها وتسجيل ما يتعلمه أثناء التحقيق في طرق تحسين برنامج.
مهارات مشابهة
diffs
394kيتيح لوكيلك إنتاج فرق تعديلات حقيقي يمكن مشاركته، كرابط عرض أو ملف صورة، بدلاً من ملخص مكتوب يدوياً.
coding-agent
394kيساعد وكيلك على تسليم مهمة برمجة كبيرة إلى Codex أو Claude Code أو OpenCode كعامل في الخلفية، ثم متابعة تقدمها.
gh-issues
394kيساعد وكيلك على إيجاد مشكلات GitHub واختيار ما ستعمل عليه، وفتح طلبات سحب بالإصلاحات، ومتابعة تعليقات المراجعة.