fallback-code-execution
ما الذي تفعله
هذه المهارة حل بديل لتشغيل شيفرة Python عندما تفشل بيئة الشيفرة مرارًا بأخطاء عامة أو غير مستقرة. وهي مناسبة لمن يشغّل الذكاء الاصطناعي شيفرة يجب أن تعطي نتائج.
متى تستخدمها
- ✓عندما تفشل بيئة الشيفرة مرتين متتاليتين أو أكثر بالشيفرة نفسها.
- ✓عندما تكون الأخطاء عامة وتشير إلى مشكلة في البيئة لا إلى خطأ في الشيفرة.
- ✓عندما أريد حفظ السكربت كملف حتى يمكن فحصه وتشغيله مرة أخرى.
رابط المهارة
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-code-execution/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“بيئة الشيفرة تُرجع أخطاء عامة على سكربتي، والمنطق صحيح. من فضلك احفظه كملف وشغّله.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يكتب الذكاء الاصطناعي السكربت في مساحة العمل باسم وصفي، ويثبّت التبعيات أولًا، ويشغّله من الطرفية مع تسجيل الناتج.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Fallback Code Execution Workflow
Overview
This skill defines a robust workaround for executing code (specifically Python) when the primary execute_code_sandbox tool fails repeatedly with unknown or transient errors. Instead of continuing to retry the failing tool, the agent switches to a manual file-write and shell-execution pattern.
Trigger Conditions
Activate this workflow when:
execute_code_sandboxfails 2 or more times consecutively for the same logic.- Error messages are generic, unknown, or indicate environment issues rather than syntax errors.
- The code logic itself is verified correct but the execution environment is unstable.
Procedure
Step 1: Write Script to File
Use the write_file tool to save the Python script to a specific path in the workspace.
- Path: Choose a descriptive name ending in
.py(e.g.,scripts/generate_report.py). - Content: Ensure the script includes necessary error handling and print statements for debugging.
- Dependencies: If the script requires external libraries, ensure a
requirements.txtis updated or installed via shell beforehand.
Example:
tool: write_file
path: workspace/scripts/process_data.py
content: |
import sys
# ... script logic ...
print("Success")
Step 2: Execute via Shell
Use the run_shell tool to execute the script using the system Python interpreter.
- Command:
python3 <path_to_script>orpython <path_to_script>. - Working Directory: Ensure the shell command runs from the workspace root or the directory containing the script.
- Capture Output: Store stdout and stderr for verification.
Example:
tool: run_shell
command: python3 scripts/process_data.py
Step 3: Verify Execution
- Check Exit Code: Ensure the shell command returned exit code
0. - Check Output: Verify expected files were created or expected stdout messages appeared.
- Handle Errors: If the shell execution fails, inspect the stderr output. This often provides more detailed tracebacks than the sandbox tool.
Best Practices
- Absolute Paths: When writing scripts that access files, use absolute paths or resolve paths relative to
__file__to avoid working directory issues. - Permissions: Ensure the workspace directory allows file creation and execution.
- Cleanup: Optionally remove temporary scripts after successful execution if cleanliness is required.
- Logging: Add explicit
print()statements in the Python script to log progress, as shell output capture is sometimes more reliable than sandbox return values.
Example Scenario
Problem: execute_code_sandbox times out while generating a PDF.
Solution:
- Write
generate_pdf.pytoworkspace/scripts/. - Run
python3 workspace/scripts/generate_pdf.pyviarun_shell. - Confirm
output.pdfexists in the workspace.
الأسئلة الشائعة
لماذا يُحفظ السكربت كملف؟
يمكن فحص الملف المحفوظ وتعديله وتشغيله مرة أخرى دون إعادة كتابة الشيفرة.
أين يُحفظ السكربت؟
في مساحة العمل، باسم وصفي ينتهي بالامتداد .py.
ماذا لو احتاج الأمر إلى حزم؟
يذكر الدليل تثبيتها أولًا من ملف المتطلبات أو من الطرفية.
التفاصيل
الوصف الأصلي من المؤلف
Fallback workflow for running code via file write and shell when sandbox execution fails
repo: HKUDS/AgentPilot
الشعبية
- نجوم GitHub
- 7.8k
- الترتيب
- #12879
- الترخيص
- 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 واختيار ما ستعمل عليه، وفتح طلبات سحب بالإصلاحات، ومتابعة تعليقات المراجعة.