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

sandbox-fallback-python

O que ela faz

Esta skill orienta o agente de IA a rodar Python pelo shell quando o sandbox não pode ser acessado. É para pessoas cujas tarefas em Python dependem de pacotes e de geração de arquivos.

Quando usar

  • ✓Quando o sandbox informa que está indisponível ou que a conexão falhou.
  • ✓Quando um script Python precisa de pacotes que devem ser instalados antes.
  • ✓Quando um script precisa ler ou gravar arquivos na pasta de trabalho.

Link da skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python/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/sandbox-fallback-python/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 sandbox está indisponível. Instale os pacotes que meu script precisa, depois execute e salve a saída na minha pasta de trabalho.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente instala os pacotes com pip e depois executa o código Python pelo shell com um heredoc. Usa caminhos explícitos para os arquivos e lista a pasta para confirmar que a saída foi salva.

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

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

Sandbox Fallback: Python via run_shell

When to Use This Skill

Apply this skill when execute_code_sandbox fails with errors indicating:

  • e2b service unavailability
  • Sandbox timeout or connection issues
  • Code execution environment not accessible

This fallback allows you to execute Python code directly via shell, bypassing the sandbox infrastructure.

Fallback Procedure

Step 1: Detect Sandbox Failure

Identify fallback necessity from error messages like:

  • "e2b unavailable"
  • "sandbox connection failed"
  • "execution environment error"
  • Timeout errors during code execution

Step 2: Switch to run_shell with Embedded Python

Instead of execute_code_sandbox, use run_shell with a Python heredoc or inline script:

python3 << 'EOF'
# Your Python code here
print("Hello from fallback execution")
EOF

Step 3: Install Dependencies First

If your Python code requires packages not guaranteed to be installed:

pip install package_name package_name2 && python3 << 'EOF'
# Your Python code here
import package_name
print("Code with dependencies executed")
EOF

Step 4: Handle File I/O

For scripts that need to read/write files:

  • Use absolute or explicit relative paths
  • Files persist in the workspace directory
  • List directory contents with ls to verify file operations
python3 << 'EOF'
import os
# Write output to file
with open("output.txt", "w") as f:
    f.write("Results here")
# Verify
print(f"Working directory: {os.getcwd()}")
EOF

Code Examples

Simple Calculation

python3 << 'EOF'
result = sum(range(100))
print(f"Sum: {result}")
EOF

With Package Installation

pip install requests -q && python3 << 'EOF'
import requests
response = requests.get("https://api.example.com/data")
print(response.json())
EOF

With JSON Processing

python3 << 'EOF'
import json

data = {"key": "value", "count": 42}
output = json.dumps(data, indent=2)
print(output)

# Save to file
with open("data.json", "w") as f:
    f.write(output)
EOF

Best Practices

  1. Use heredoc syntax - << 'EOF' prevents variable expansion issues
  2. Install quietly - Use pip install -q to reduce output noise
  3. Error handling - Add try/except blocks in Python code for robustness
  4. Verify execution - Check stdout/stderr from run_shell to confirm success
  5. Keep code compact - Long scripts are harder to debug in shell context

Caveats

  • No persistent state between run_shell calls (unlike execute_code_sandbox)
  • Longer execution time for complex scripts due to Python interpreter startup
  • Limited debugging - Cannot easily inspect variables between statements
  • Output size limits - Very large outputs may be truncated

When NOT to Use This Fallback

  • If the task specifically requires sandbox isolation for security
  • If you need persistent state across multiple code executions
  • If the code execution is extremely long-running (consider backgrounding)
Perguntas frequentes

Como o agente confere a saída?

Ele lê as mensagens do shell e lista a pasta para ver os novos arquivos.

Por que usar caminhos explícitos?

Caminhos explícitos garantem que os arquivos sejam salvos na pasta de trabalho que você espera.

Funciona sem instalar nada?

Se os pacotes já estiverem presentes, a etapa de instalação pode ser pulada.

Detalhes

Descrição original do autor

Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability

repo: HKUDS/AgentPilot

Popularidade

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

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas