pdf-gen-fallback-501bcc
하는 일
이 스킬은 샌드박스가 불분명한 메시지로 실패할 때 문서를 만드는 예비 방법입니다. 샌드박스가 믿을 수 없어도 PDF나 Word 파일이 필요한 사람에게 맞습니다.
사용하는 경우
- ✓문서를 만드는 중 코드 샌드박스가 불분명한 오류로 실패할 때.
- ✓샌드박스에 필요한 Python 라이브러리가 없는 것 같은 경우.
- ✓이 컴퓨터에 PDF나 Word 파일을 만들어야 할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-gen-fallback-501bcc/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“샌드박스가 PDF를 만드는 동안 불분명한 오류로 계속 실패합니다. 라이브러리를 확인하고 셸에서 만들어 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 reportlab, fpdf2, pypdf, python-docx가 설치되어 있는지 확인하고, 없는 것은 pip으로 설치한 뒤, 셸에서 python 명령으로 문서를 생성합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PDF Generation Fallback Pattern
When to Use
Apply this pattern when execute_code_sandbox returns opaque or unhelpful errors during PDF, DOCX, or other document generation tasks. This fallback uses run_shell with direct python -c execution for more reliable document generation.
Step-by-Step Procedure
1. Detect Sandbox Failure
If execute_code_sandbox fails during document generation with errors like:
- Opaque runtime errors
- Missing library errors that don't resolve with import statements
- Silent failures with no output
Proceed to the fallback approach.
2. Check Library Availability
Before generating documents, verify the required Python libraries are available in the shell environment:
python -c "import reportlab; print('OK')" 2>&1 || echo "reportlab missing"
python -c "import fpdf; print('OK')" 2>&1 || echo "fpdf missing"
python -c "import pypdf; print('OK')" 2>&1 || echo "pypdf missing"
python -c "import docx; print('OK')" 2>&1 || echo "python-docx missing"
3. Install Missing Libraries (If Needed)
If a library is missing, install it via pip:
pip install reportlab fpdf2 pypdf python-docx
4. Execute Document Generation via run_shell
Use run_shell with python -c and multi-line strings for document generation:
python -c "
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas('output.pdf', pagesize=letter)
c.drawString(100, 750, 'Document Title')
c.drawString(100, 700, 'Content here')
c.save()
print('SUCCESS: PDF created')
"
For DOCX files:
python -c "
from docx import Document
doc = Document()
doc.add_heading('Document Title', 0)
doc.add_paragraph('Content here')
doc.save('output.docx')
print('SUCCESS: DOCX created')
"
5. Include Explicit Error Handling
Always wrap generation code with try/except for clear error reporting:
python -c "
try:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas('output.pdf', pagesize=letter)
c.drawString(100, 750, 'Content')
c.save()
print('SUCCESS')
except ImportError as e:
print(f'MISSING_LIBRARY: {e}')
exit(1)
except Exception as e:
print(f'GENERATION_ERROR: {e}')
exit(1)
"
6. Verify Output File
After generation, confirm the file was created and is valid:
ls -la output.pdf
file output.pdf
test -f output.pdf && echo "File exists" || echo "File missing"
Complete Example Workflow
# Step 1: Check and install library
python -c "import reportlab" 2>&1 || pip install reportlab
# Step 2: Generate PDF with error handling
python -c "
try:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas('report.pdf', pagesize=letter)
c.setFont('Helvetica', 12)
c.drawString(100, 750, 'Surveillance Report')
c.drawString(100, 700, 'Generated via fallback pattern')
c.save()
print('SUCCESS: report.pdf created')
except Exception as e:
print(f'ERROR: {e}')
exit(1)
"
# Step 3: Verify
test -f report.pdf && echo "Verification: PASSED" || echo "Verification: FAILED"
Why This Works
- Direct Execution:
run_shellwithpython -cbypasses sandbox limitations that may affect document generation libraries - Explicit Errors: Try/except blocks provide actionable error messages instead of opaque failures
- Environment Control: Shell execution gives more control over the Python environment and library paths
- Verification: Explicit file checks confirm success rather than assuming it
Common Libraries
| Library | Purpose | Import Statement |
|---|---|---|
| reportlab | PDF generation | from reportlab.pdfgen import canvas |
| fpdf2 | PDF generation | from fpdf import FPDF |
| pypdf | PDF manipulation | from pypdf import PdfReader |
| python-docx | DOCX generation | from docx import Document |
| xlsxwriter | Excel files | import xlsxwriter |
자주 묻는 질문
어떤 라이브러리를 확인하나요?
가이드는 reportlab, fpdf2, pypdf, python-docx를 확인합니다.
없는 라이브러리는 어떻게 추가하나요?
문서를 만들기 전에 pip으로 설치합니다.
Word 파일에도 작동하나요?
네, python-docx는 가이드가 Word 문서용으로 확인하는 라이브러리 중 하나입니다.
상세 정보
작성자의 원본 설명
Fallback pattern for PDF/document generation when execute_code_sandbox fails with opaque errors
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12926
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
feishu-doc
394k에이전트가 문서 도구를 사용해 텍스트, 이미지, 표를 포함한 Feishu 클라우드 문서를 읽고, 만들고, 편집하도록 돕습니다.
feishu-drive
394k에이전트가 봇과 공유된 Feishu 클라우드 폴더의 파일을 찾아보고, 정리하고, 댓글을 달도록 돕습니다.
feishu-perm
394k에이전트가 요청을 충족하는 가장 작은 권한을 골라, Feishu 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.