python-shell-fallback
하는 일
이 스킬은 샌드박스에 패키지가 없을 때 라이브러리 기반 Python 작업을 셸로 옮기도록 돕습니다. PDF나 차트처럼 라이브러리가 많이 필요한 결과물을 원하는 사람에게 맞습니다.
사용하는 경우
- ✓샌드박스가 ModuleNotFoundError나 비슷한 가져오기 오류를 낼 때.
- ✓샌드박스에 필요한 라이브러리가 없어 PDF나 차트가 필요한 경우.
- ✓샌드박스 실행이 패키지 문제로 계속 실패할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-shell-fallback/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 텍스트로 PDF 보고서를 만들어 주세요. 샌드박스가 모듈이 없다고 하니 셸에서 실행해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 누락된 패키지 오류를 알아차리고, 코드를 heredoc을 이용해 셸에서 실행하도록 고칩니다. 셸 환경에는 보통 더 많은 설치된 패키지가 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Python Shell Fallback
When execute_code_sandbox fails for Python code that depends on external libraries, use run_shell with a heredoc Python script as a reliable fallback. The shell environment typically has better access to installed packages and system configuration than the sandbox.
When to Use This Pattern
Apply this skill when:
execute_code_sandboxreturns errors related to missing libraries (e.g.,ModuleNotFoundError)- The code requires packages that may not be installed in the sandbox environment
- You need PDF generation, data visualization, or other library-heavy operations
- Previous sandbox execution attempts have failed with import errors
How to Implement
Step 1: Identify the Failure
Check if the sandbox error indicates a library/dependency issue:
ModuleNotFoundError: No module named 'xxx'ImportError: cannot import name 'xxx'- Similar package-related errors
Step 2: Convert to Shell Execution
Rewrite the code execution using run_shell with a heredoc:
python3 << 'EOF'
# Your Python code here
import library_name
# ... rest of code
EOF
Step 3: Execute via run_shell
Call run_shell with the heredoc Python script:
command: python3 << 'EOF'
import reportlab
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
# Your library-dependent code here
c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello World")
c.save()
EOF
Example: PDF Generation Fallback
Sandbox attempt (fails):
# execute_code_sandbox call fails with:
# ModuleNotFoundError: No module named 'reportlab'
Shell fallback (works):
python3 << 'EOF'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("legal_memo.pdf", pagesize=letter)
c.setTitle("Legal Memorandum")
c.drawString(100, 750, "CONFIDENTIAL LEGAL MEMORANDUM")
c.save()
print("PDF created successfully")
EOF
Best Practices
- Use quoted heredoc (
<< 'EOF') - Prevents variable expansion, keeping Python code intact - Verify output - Check stdout/stderr from
run_shellto confirm success - Handle file paths - Ensure output files are written to accessible directories
- Test incrementally - For complex scripts, test in smaller chunks first
- Include error handling - Add try/except blocks to capture issues gracefully
Alternative: Inline Python Command
For simple one-liners or short scripts:
python3 -c "import reportlab; print(reportlab.__version__)"
Troubleshooting
If shell execution also fails:
- Check if Python3 is available:
which python3 - Verify package installation:
pip3 list | grep package_name - Try
pythoninstead ofpython3(some systems differ) - Consider installing the package:
pip3 install package_name
자주 묻는 질문
어떤 오류가 전환 신호인가요?
ModuleNotFoundError나 패키지에 대한 ImportError 같은 오류가 전환 신호입니다.
PDF 파일도 만들 수 있나요?
스킬은 reportlab 같은 라이브러리로 PDF를 만드는 것을 한 예로 언급합니다.
항상 작동하나요?
스킬은 셸에 패키지가 설치되어 있다고 가정하므로, 설치되어 있지 않으면 여전히 실패할 수 있습니다.
상세 정보
작성자의 원본 설명
Fallback to shell execution when sandbox fails for library-dependent Python code
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12961
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.