execute-code-fallback
하는 일
이 스킬은 코드 샌드박스에 연결할 수 없거나 시간이 초과되면 셸에서 Python을 실행하도록 AI에게 안내합니다. 샌드박스 서비스가 멈춰도 코드가 실행되어야 하는 사람에게 맞습니다.
사용하는 경우
- ✓코드 샌드박스가 사용할 수 없다거나 연결할 수 없다고 보고할 때.
- ✓샌드박스가 두 번 이상 연속으로 시간 초과되거나 실패한 경우.
- ✓실행 전에 추가 패키지를 설치해야 하는 코드일 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/execute-code-fallback/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“지금 코드 샌드박스가 작동하지 않습니다. Python 스크립트를 셸에서 실행해 주시고, 필요한 패키지는 먼저 설치해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 pip으로 필요한 패키지를 설치한 뒤, 셸 명령으로 Python 코드를 실행합니다. 긴 스크립트에는 heredoc을 사용합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Execute Code Fallback Pattern
When execute_code_sandbox fails due to e2b unavailability, immediately fall back to run_shell with embedded Python code. This ensures task continuity when the sandbox service is down.
When to Apply
Use this pattern when you observe:
execute_code_sandboxreturns errors mentioning "e2b", "sandbox unavailable", or connection timeouts- Repeated sandbox execution failures (2+ attempts)
- Error messages indicating the code execution environment is unreachable
Fallback Procedure
Step 1: Detect the Failure
Identify that execute_code_sandbox has failed. Common error indicators:
- "e2b service unavailable"
- "Sandbox connection failed"
- "Execution environment not reachable"
- Timeout errors during code execution
Step 2: Switch to run_shell with Embedded Python
Instead of:
execute_code_sandbox(code="...")
Use:
run_shell(command="python3 -c '...your Python code...'")
Step 3: Install Dependencies First (If Needed)
If your Python code requires external packages, install them first:
run_shell(command="pip install pandas requests matplotlib")
Then execute your main code:
run_shell(command="python3 << 'EOF'
import pandas as pd
import requests
# Your code here
print("Success")
EOF
")
Step 4: Use Heredoc for Multi-line Code
For complex Python scripts, use heredoc syntax for cleaner code:
run_shell(command="python3 << 'PYTHON_SCRIPT'
import json
import os
# Complex logic here
data = {'key': 'value'}
with open('output.json', 'w') as f:
json.dump(data, f)
print('File created successfully')
PYTHON_SCRIPT
")
Complete Example
Scenario: You need to process a CSV file and generate a report.
Original approach (sandbox):
execute_code_sandbox(code="""
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
""")
Fallback approach (run_shell):
# First install dependencies if needed
run_shell(command="pip install pandas --quiet")
# Then execute the code
run_shell(command="python3 << 'EOF'
import pandas as pd
df = pd.read_csv('data.csv')
summary = df.describe()
print(summary)
EOF
")
Important Considerations
State Persistence: Unlike
execute_code_sandbox,run_shellexecutions may not share state between calls. Save intermediate results to files if needed.Working Directory: Ensure you're operating in the correct directory. Use
pwdto verify or includecd /path/to/workdirin your commands.Python Version: Use
python3explicitly to avoid ambiguity. Verify withpython3 --versionif needed.Error Handling: Check the stdout/stderr from
run_shellto confirm success. Failed Python scripts will return non-zero exit codes.Security: Be cautious when embedding user-provided data into shell commands. Escape appropriately or use file-based input.
Performance: For large computations,
run_shellmay be slower than sandbox. Consider breaking into smaller steps if timeouts occur.
Quick Reference
| Task | Sandbox Approach | Fallback Approach |
|---|---|---|
| Simple calculation | execute_code_sandbox(code="print(2+2)") |
run_shell(command="python3 -c 'print(2+2)'") |
| Install + run | execute_code_sandbox(code="import pkg; ...") |
run_shell(command="pip install pkg && python3 -c '...'") |
| Multi-line script | execute_code_sandbox(code="...") |
run_shell(command="python3 << 'EOF'...EOF") |
| File I/O | execute_code_sandbox(code="...") |
run_shell(command="python3 << 'EOF'...EOF") |
Recovery Checklist
- Confirm
execute_code_sandboxfailure (not a code bug) - Switch to
run_shellimmediately - Install required packages with
pip install - Use heredoc for multi-line Python
- Verify output and handle errors
- Save intermediate results to files if multi-step
자주 묻는 질문
어떤 오류가 전환을 일으키나요?
샌드박스 사용 불가, 연결 시간 초과, 실행 환경에 닿지 않음 같은 메시지를 가이드가 언급합니다.
패키지는 어떻게 추가하나요?
가이드는 주요 코드를 실행하기 전에 pip으로 먼저 설치합니다.
왜 heredoc을 쓰나요?
여러 줄로 된 스크립트를 셸 명령 하나로 실행할 수 있기 때문입니다.
상세 정보
작성자의 원본 설명
Fallback from execute_code_sandbox to run_shell when e2b sandbox is unavailable
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12878
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.