Reliable PDF generation using shell-based Python execution when sandbox fails
59
67%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./benchmarks/gdpval/skills/pdf-gen-fallback/SKILL.mdThis skill provides a reliable workflow for generating PDFs and documents when execute_code_sandbox returns opaque errors. Use direct run_shell with python -c as a fallback, with library availability checks and explicit error handling.
execute_code_sandbox fails with cryptic error messages during document/PDF generationBefore attempting generation, verify that required libraries are installed:
run_shell command="python -c \"import reportlab; print('reportlab available')\""
run_shell command="python -c \"import fpdf; print('fpdf available')\""
run_shell command="python -c \"import pypdf; print('pypdf available')\""Try the sandbox approach initially (it's cleaner for iteration):
execute_code_sandbox code="""
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Document Content")
c.save()
print("ARTIFACT_PATH:/path/to/output.pdf")
"""Watch for these failure indicators:
If sandbox fails, use direct shell execution:
run_shell command="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 Content')
c.save()
print('PDF created successfully')
\""After generation, confirm the file exists:
run_shell command="ls -la output.pdf && file output.pdf"1. Check libraries: run_shell "python -c \"import reportlab\""
2. Try sandbox: execute_code_sandbox with PDF generation code
3. If error detected: Fall back to run_shell with python -c
4. Verify: run_shell "ls -la *.pdf"
5. Read result: read_file filetype="pdf" file_path="output.pdf"run_shell command="pip install reportlab"If reportlab is unavailable, try:
fpdf - Simpler API, good for basic PDFsweasyprint - HTML/CSS to PDF conversionpypdf - PDF manipulation and mergingc5a9c4b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.