Reliable Python execution workflow when execute_code_sandbox or shell_agent fail
63
73%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Critical
Do not install without reviewing
Fix and improve this skill with Tessl
tessl review fix ./benchmarks/gdpval/skills/fallback-python-execution/SKILL.mdUse this pattern when:
execute_code_sandbox returns unknown errors or fails repeatedlyshell_agent cannot successfully execute Python codeInstead of delegating Python execution to agents, use this two-step inline approach:
.py file using write_filerun_shell with python <script.py>Use write_file to create a Python script with all necessary code inline:
write_file
path: /path/to/script.py
content: |
import pandas as pd
# Your complete Python code here
df = pd.DataFrame({...})
df.to_excel('output.xlsx', index=False)Run the script directly:
run_shell
command: python /path/to/script.pyThis approach is more reliable because:
# Step 1: Write the script
write_file:
path: create_report.py
content: |
import pandas as pd
from openpyxl import Workbook
# Create data
data = {'Column1': [1, 2, 3], 'Column2': ['A', 'B', 'C']}
df = pd.DataFrame(data)
# Save to Excel
df.to_excel('report.xlsx', index=False)
print('Excel file created successfully')
# Step 2: Execute
run_shell:
command: python create_report.py| Issue | Solution |
|---|---|
| Module not found | Add pip install commands before python command |
| Permission errors | Check file paths are writable |
| Script not found | Use absolute path or cd to directory first |
| Output not created | Check for Python errors in run_shell output |
c5a9c4b
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.