sandbox-fallback-python-e5d7ae
하는 일
이 스킬은 샌드박스가 시작되거나 연결되지 않을 때 AI 에이전트가 셸로 Python 코드를 실행하는 방법을 설명합니다. reportlab이나 pandas 같은 라이브러리를 쓰는 사람을 위한 스킬입니다.
사용하는 경우
- ✓샌드박스가 초기화, 시작 또는 연결 오류를 보일 때.
- ✓짧은 스크립트를 셸에서 바로 실행해야 할 때.
- ✓긴 스크립트는 파일로 저장하고 더 긴 제한 시간으로 실행해야 할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python-e5d7ae/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“샌드박스가 시작되지 않습니다. reportlab으로 제 PDF 청구서를 만들도록 셸에서 스크립트를 실행해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
짧은 코드는 에이전트가 셸 명령 안에 heredoc으로 넣어 실행합니다. 긴 코드는 임시 파일에 쓰고 실행하며, 필요하면 작업에 더 많은 시간을 줍니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Python Sandbox Fallback Pattern
When to Use
Use this pattern when execute_code_sandbox fails with e2b/sandbox initialization errors, especially when running Python code that requires external libraries like reportlab, pandas, numpy, etc.
Common Failure Indicators
Detect these error patterns to trigger the fallback:
e2binitialization errorssandboxcreation/creation timeout failurescontainerstartup errors- Connection/refusal errors from sandbox service
The Fallback Pattern
Basic Heredoc Approach
For short scripts, use a Python heredoc directly in run_shell:
run_shell(
command="""python3 << 'EOF'
import sys
print(f"Python version: {sys.version}")
# Your code here
EOF
""",
timeout=60
)
File-Based Approach for Complex Scripts
For longer scripts or when you need to preserve state across multiple executions:
# Step 1: Write the script to a temporary file
script_content = '''
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
import os
# Your code here
'''
run_shell(command=f"cat > /tmp/script.py << 'SCRIPT_EOF'\n{script_content}\nSCRIPT_EOF")
# Step 2: Execute the script
result = run_shell(command="python3 /tmp/script.py", timeout=120)
Key Considerations
Timeouts
run_shelltypically needs longer timeouts thanexecute_code_sandbox- Use
timeout=60for simple scripts - Use
timeout=120or higher for library-heavy operations (PDF generation, data processing)
Library Availability
- Verify required libraries are installed in the shell environment
- Install missing libraries first if needed:
run_shell(command="pip install reportlab", timeout=60)
Error Handling
- Capture and inspect
run_shelloutput for Python errors - Check stderr for import failures or runtime exceptions
Working Directory
- Files created via
run_shellare in the current working directory by default - Use absolute paths or
os.getcwd()to reference files reliably
Example: PDF Generation with reportlab
# FALLBACK VERSION (when execute_code_sandbox fails):
pdf_code = """
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def create_memo(filename):
c = canvas.Canvas(filename, pagesize=letter)
c.drawString(1*inch, 10*inch, "Legal Memorandum")
c.save()
print(f"Created {filename}")
create_memo('/workspace/output.pdf')
"""
# Write script to file
run_shell(command=f"cat > /tmp/create_pdf.py << 'PYEOF'\n{pdf_code}\nPYEOF")
# Execute and verify
run_shell(command="python3 /tmp/create_pdf.py", timeout=120)
# Verify output exists
run_shell(command="ls -la /workspace/output.pdf", timeout=30)
Comparison Table
| Aspect | execute_code_sandbox | run_shell (fallback) |
|---|---|---|
| Isolation | High (containerized) | Low (host environment) |
| Reliability | Can fail with e2b errors | More reliable |
| Library Access | Pre-configured sandbox | Depends on host |
| Timeout | Default 30s | Configurable |
| File Access | ARTIFACT_PATH convention | Direct filesystem |
Migration Checklist
When switching from execute_code_sandbox to run_shell:
- Increase timeout values (typically 2-4x)
- Convert ARTIFACT_PATH references to actual file paths
- Add explicit file verification steps after execution
- Handle potential library import errors
- Test script execution in shell environment first
자주 묻는 질문
제한 시간을 왜 길게 잡나요?
스킬은 셸 실행이 보통 샌드박스 실행보다 더 많은 시간이 필요하다고 설명합니다.
임시 파일은 어디에 보관되나요?
스킬의 예시는 임시 폴더에 파일을 쓰지만, 에이전트가 다른 위치를 고를 수도 있습니다.
어떤 라이브러리를 언급하나요?
코드에 필요할 수 있는 예로 reportlab, pandas, numpy를 언급합니다.
상세 정보
작성자의 원본 설명
Fallback to run_shell with Python heredoc when execute_code_sandbox fails
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12991
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.