Aller au contenu
Skillpedia
Programmation générale7.8k · #12879

fallback-code-execution

Ce qu’il fait

Ce skill est une solution de contournement pour exécuter du code Python lorsque le bac à sable échoue sans cesse avec des erreurs inconnues ou instables. Il s'adresse aux personnes dont l'IA exécute du code qui doit produire des résultats.

Quand l’utiliser

  • ✓Quand le bac à sable a échoué deux fois ou plus de suite avec le même code.
  • ✓Quand les erreurs sont génériques et laissent penser à un problème d'environnement plutôt qu'à une erreur de code.
  • ✓Quand je veux garder le script sous forme de fichier, pour pouvoir le vérifier et le relancer.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-code-execution/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Le bac à sable renvoie sans cesse des erreurs génériques sur mon script, et la logique est juste. Enregistre-le dans un fichier et lance-le.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'IA écrit le script dans l'espace de travail sous un nom explicite, installe d'abord les dépendances, puis le lance par le shell en capturant la sortie.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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.
Questions fréquentes

Pourquoi garder le script sous forme de fichier ?

Un fichier enregistré peut être examiné, modifié et relancé sans réécrire le code.

Où le script est-il enregistré ?

Dans l'espace de travail, sous un nom explicite se terminant par .py.

Et si des paquets sont nécessaires ?

Le guide demande de les installer au préalable, à partir d'un fichier de dépendances ou via le shell.

Détails

Description originale de l’auteur

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

repo: HKUDS/AgentPilot

Popularité

Étoiles GitHub
7.8k
Position au classement
#12879
Licence
MIT
Mis à jour
01/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires