Pular para o conteúdo
Skillpedia
Código em geral7,8 mil · #12844

code-exec-fallback-266cba

O que ela faz

Esta skill diz à IA para mudar de método quando o executor de código embutido continua falhando. Ela é para quem tem tarefas de IA que precisam que código Python rode com sucesso.

Quando usar

  • ✓Quando o sandbox de código falha duas vezes seguidas com erros pouco claros.
  • ✓Quando as execuções de código excedem o tempo limite e tentar de novo não ajuda.
  • ✓Quando preciso que um script Python rode pela linha de comando, em vez do sandbox.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/code-exec-fallback-266cba/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“O executor de código continua falhando no meu script de dados. Rode de outro jeito e me mostre a saída.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A IA escreve o código Python em um arquivo, executa com um comando de shell, lê a saída e os erros, e informa se funcionou.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do GitHub.

Code Execution Fallback Pattern

When to Use This Skill

Apply this pattern when you encounter repeated failures with execute_code_sandbox:

  • 2+ consecutive failures with opaque or unknown errors
  • Timeout errors that persist across retry attempts
  • Environment-related errors that don't resolve with code fixes

The Fallback Workflow

Step 1: Detect Repeated Failures

Track execution failures. After 2 consecutive failures with execute_code_sandbox, switch to the fallback approach.

Step 2: Write Script to File

Use write_file to save your Python script:

write_file(
    path="/workspace/script_name.py",
    content="# Your Python code here\nimport sys\n..."
)

Step 3: Execute via Shell

Use run_shell to run the script:

run_shell(
    command="python /workspace/script_name.py",
    timeout=300
)

Step 4: Capture Output

Parse stdout/stderr from run_shell output to verify success or diagnose issues.

Complete Example

# Instead of this (which may fail):
result = execute_code_sandbox(code="import pandas as pd\n...")

# Use this fallback pattern:
script_content = """
import pandas as pd
import sys

try:
    # Your logic here
    df = pd.DataFrame({'col': [1, 2, 3]})
    print(df.to_csv())
    sys.exit(0)
except Exception as e:
    print(f"ERROR: {e}", file=sys.stderr)
    sys.exit(1)
"""

# Write the script
write_file(path="/workspace/my_script.py", content=script_content)

# Execute via shell
result = run_shell(command="python /workspace/my_script.py", timeout=300)

Best Practices

  1. Add error handling in your script - use try/except with sys.exit() codes
  2. Set appropriate timeouts - run_shell default is 30s, increase for heavy operations
  3. Clean up temporary files after execution if needed
  4. Log the fallback trigger - document why you switched approaches
  5. Verify Python availability - Most sandboxes have Python 3.x by default

Why This Works

  • write_file is more reliable for file I/O operations
  • run_shell gives you direct control over execution environment
  • Shell execution bypasses sandbox serialization issues
  • Better error visibility through stdout/stderr streams

When NOT to Use This Pattern

  • First-time execution failures (retry the sandbox first)
  • Simple one-liner code (sandbox is faster)
  • When sandbox errors are clearly code bugs (fix the code instead)
  • Security-sensitive operations requiring sandbox isolation
Perguntas frequentes

O que conta como falha?

O guia aponta erros repetidos, erros desconhecidos ou tempos limite do sandbox.

Posso ver os erros?

Sim. A saída e as mensagens de erro são capturadas para que a IA possa informar o que deu errado.

Por que escrever o código em um arquivo?

O guia diz que essa rota pode funcionar quando o sandbox falhou repetidamente.

Detalhes

Descrição original do autor

Fallback workflow for reliable code execution when sandbox fails repeatedly

repo: HKUDS/AgentPilot

Popularidade

Estrelas no GitHub
7,8 mil
Posição no ranking
#12844
Licença
MIT
Atualizada em
01/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas