Langsung ke konten
Skillpedia
Pemrograman umum7.8k Β· #13001

shell-python-fallback

Fungsinya

Skill ini memberi agent AI cadangan untuk pekerjaan Python saat alat kodenya mengembalikan error tidak diketahui. Skill ini ditujukan untuk orang yang memerlukan pemrosesan data atau pembuatan PDF yang dilakukan dengan andal.

Kapan dipakai

  • βœ“Saat alat kode mengembalikan error tidak diketahui dua kali atau lebih untuk pekerjaan yang sama.
  • βœ“Saat Anda memerlukan pemrosesan data, penguraian file, atau pembuatan PDF dengan Python.
  • βœ“Saat skrip perlu dijalankan dan Anda menginginkan output yang jelas untuk diperiksa.

Link skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-python-fallback/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-python-fallback/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œAlat kode saya terus memberi error tidak diketahui pada pembersihan data ini. Jalankan Python lewat shell dan tunjukkan outputnya kepada saya.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent menyisipkan skrip Python ke dalam perintah shell menggunakan heredoc. Agent menjalankannya, membaca output yang ditampilkan untuk memeriksa keberhasilan atau error, dan menyesuaikan kode jika perlu.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Shell Python Fallback

When to Use

Use this pattern when execute_code_sandbox or shell_agent tools consistently fail with "unknown error" for tasks such as:

  • Data processing and transformation
  • PDF generation (reportlab, etc.)
  • File parsing and manipulation
  • Any Python script execution that requires reliability

The Pattern

Instead of using code execution tools, embed your Python script directly in a run_shell command using a heredoc:

python3 << 'EOF'
# Your Python code here
import sys
print("Hello from embedded Python")
EOF

Step-by-Step Instructions

  1. Identify the failure: When execute_code_sandbox or shell_agent returns "unknown error" repeatedly (2+ attempts), switch to this fallback.

  2. Write your Python script: Prepare the complete Python code you need to execute.

  3. Embed in run_shell: Use run_shell with a heredoc syntax:

Command: python3 << 'EOF'
import json
# Your complete script here
data = {"key": "value"}
print(json.dumps(data))
EOF
  1. Handle multi-line scripts: For longer scripts, ensure proper indentation is preserved. The heredoc preserves whitespace exactly.

  2. Check output: Parse the stdout from run_shell to verify success or capture errors.

Example: PDF Generation

python3 << 'EOF'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello World")
c.save()
print("PDF created successfully")
EOF

Example: Data Processing

python3 << 'EOF'
import csv
import json

data = []
with open('input.csv', 'r') as f:
    reader = csv.DictReader(f)
    for row in reader:
        data.append(row)

with open('output.json', 'w') as f:
    json.dump(data, f, indent=2)

print(f"Processed {len(data)} records")
EOF

Best Practices

  • Quote the EOF delimiter (<< 'EOF' not << EOF) to prevent shell variable expansion in your Python code
  • Include error handling in your Python script with try/except blocks
  • Print status messages to stdout so you can verify execution succeeded
  • Use absolute paths or ensure working directory is correct
  • Test incrementally: Start with a minimal script, then expand

Troubleshooting

Issue Solution
Script doesn't run Ensure python3 is available in the shell environment
Indentation errors Check that heredoc preserves spaces (use spaces, not tabs)
Module not found Use python3 -m pip install <module> before running script
File not found Use absolute paths or pwd to verify working directory

Why This Works

The run_shell tool executes commands directly in the system shell, bypassing the sandbox restrictions or internal errors that affect execute_code_sandbox and shell_agent. The heredoc approach allows multi-line Python scripts while keeping everything in a single shell command.

Pertanyaan umum

Berapa kali kegagalan memicu peralihan?

Skill ini menyatakan peralihan dilakukan setelah dua atau lebih error tidak diketahui.

Apakah heredoc menjaga indentasi?

Skill ini menyatakan heredoc mempertahankan spasi dengan tepat, sehingga kode multi-baris tetap utuh.

Bisakah membuat PDF?

Bisa. Skill ini memberi contoh PDF memakai reportlab.

Detail

Deskripsi asli dari pembuat

Use run_shell with embedded Python heredoc as reliable fallback when code execution tools fail

repo: HKUDS/AgentPilot

Popularitas

Bintang GitHub
7.8k
Peringkat
#13001
Lisensi
MIT
Diperbarui
1/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa