Перейти к содержанию
Skillpedia
Код в целом7.8k · #12879

fallback-code-execution

Что он делает

Этот скилл — обходной путь для запуска кода Python, когда песочница раз за разом падает с неизвестными или нестабильными ошибками. Он нужен тем, чей ИИ запускает код, который обязан выдать результат.

Когда использовать

  • ✓Когда песочница два или более раз подряд падает на одном и том же коде.
  • ✓Когда ошибки общие и указывают на проблему окружения, а не на ошибку в коде.
  • ✓Когда хочу сохранить скрипт как файл, чтобы его можно было проверить и запустить снова.

Ссылка на скилл

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

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-code-execution/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Песочница постоянно выдаёт общие ошибки на моём скрипте, а логика верная. Сохрани его в файл и запусти.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

ИИ записывает скрипт в рабочую папку под понятным именем, сначала устанавливает зависимости и запускает его через оболочку, сохраняя вывод.

Технический текст (оригинальный 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:

  1. execute_code_sandbox fails 2 or more times consecutively for the same logic.
  2. Error messages are generic, unknown, or indicate environment issues rather than syntax errors.
  3. 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.txt is 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> or python <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

  1. Check Exit Code: Ensure the shell command returned exit code 0.
  2. Check Output: Verify expected files were created or expected stdout messages appeared.
  3. 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:

  1. Write generate_pdf.py to workspace/scripts/.
  2. Run python3 workspace/scripts/generate_pdf.py via run_shell.
  3. Confirm output.pdf exists in the workspace.
Частые вопросы

Зачем хранить скрипт как файл?

Сохранённый файл можно проверить, изменить и запустить снова без переписывания кода.

Где сохраняется скрипт?

В рабочей папке, под понятным именем с расширением .py.

Что если нужны пакеты?

Руководство советует установить их заранее из файла requirements или через оболочку.

Подробности

Оригинальное описание автора

Fallback workflow for running code via file write and shell when sandbox execution fails

repo: HKUDS/AgentPilot

Популярность

Звёзды на GitHub
7.8k
Место в рейтинге
#12879
Лицензия
MIT
Обновлён
01.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы