sandbox-fallback-python
하는 일
이 스킬은 샌드박스에 연결할 수 없을 때 AI 에이전트가 셸로 Python을 실행하도록 안내합니다. 패키지에 의존하고 파일을 출력하는 Python 작업을 하는 사람을 위한 스킬입니다.
사용하는 경우
- ✓샌드박스가 사용할 수 없다고 하거나 연결에 실패했을 때.
- ✓Python 스크립트를 실행하기 전에 패키지를 먼저 설치해야 할 때.
- ✓스크립트가 작업 폴더의 파일을 읽거나 써야 할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/sandbox-fallback-python/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“샌드박스를 쓸 수 없습니다. 스크립트에 필요한 패키지를 설치하고 실행한 다음, 결과를 제 작업 폴더에 저장해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 pip로 패키지를 설치한 뒤, heredoc을 사용해 셸로 Python 코드를 실행합니다. 파일에는 명시적인 경로를 쓰고, 폴더를 나열해 결과가 저장되었는지 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
lsto 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
- Use heredoc syntax -
<< 'EOF'prevents variable expansion issues - Install quietly - Use
pip install -qto reduce output noise - Error handling - Add try/except blocks in Python code for robustness
- Verify execution - Check stdout/stderr from run_shell to confirm success
- 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)
자주 묻는 질문
에이전트는 출력을 어떻게 확인하나요?
셸에서 나온 메시지를 읽고, 폴더를 나열해 새 파일이 생겼는지 확인합니다.
명시적인 경로는 왜 쓰나요?
명시적인 경로를 쓰면 파일이 예상한 작업 폴더에 저장되도록 보장할 수 있습니다.
설치 없이도 작동하나요?
패키지가 이미 있다면 설치 단계는 건너뛸 수 있습니다.
상세 정보
작성자의 원본 설명
Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12992
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.