Saltar al contenido
Skillpedia
Programación general7,8 mil · #12884

fallback-script-execution

Qué hace

Esta skill es un método repetible para ejecutar scripts de Python en dos pasos, lo que da mensajes de error más claros. Está pensada para quienes depuran código que no funciona con las herramientas habituales.

Cuándo usarla

  • ✓Cuando un agente auxiliar falla repetidamente con mensajes poco claros al ejecutar código.
  • ✓Cuando el entorno aislado agota el tiempo o da error con el mismo código.
  • ✓Cuando quiero corregir y volver a ejecutar un script sin reescribirlo cada vez.

Link de la skill

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

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-script-execution/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“El asistente sigue fallando al ejecutar mi script. Guárdalo como archivo y ejecútalo para que pueda ver el error completo.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La IA escribe un script independiente con gestión de errores en un archivo y luego lo ejecuta con un comando de shell, para que se vean la traza completa y la salida.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Fallback Script Execution with write_file + run_shell

When to Use This Skill

Use this pattern when:

  • shell_agent fails repeatedly with unclear error messages
  • execute_code_sandbox consistently 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:

  1. Write script to file using write_file
  2. Execute script using run_shell with python 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

  1. Add print statements at key points to trace execution
  2. Check file paths - use run_shell with ls -la path/ to verify files exist
  3. Inspect errors - run_shell output shows full Python stack traces
  4. 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_shell with which python or python --version
  • Check file permissions: run_shell with ls -la script.py
  • Try explicit Python path: run_shell with /usr/bin/python script.py
  • Consider task complexity - may need to break into smaller scripts
Preguntas frecuentes

¿Por qué es mejor un archivo para depurar?

El script queda en el disco, así que se puede revisar y volver a ejecutar tras los cambios.

¿Qué hace más clara la salida de error?

Las trazas completas aparecen en la salida de la shell en lugar de quedar ocultas.

¿Qué debe incluir el script?

Las importaciones, la lógica principal, bloques try y except, y mensajes de progreso impresos.

Detalles

Descripción original del autor

Two-step script execution workflow for debugging when shell_agent and execute_code_sandbox consistently fail

repo: HKUDS/AgentPilot

Popularidad

Estrellas en GitHub
7,8 mil
Posición en el ranking
#12884
Licencia
MIT
Actualizada
1/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas