Langsung ke konten
Skillpedia
Pemrograman umum7.8k · #12882

fallback-python-execution

Fungsinya

Skill ini adalah metode cadangan untuk menjalankan Python ketika sandbox atau helper tidak bisa melakukannya. Skill ini cocok untuk orang yang membutuhkan Python untuk membuat file data atau dokumen.

Kapan dipakai

  • ✓Saat sandbox mengembalikan galat yang tidak diketahui atau gagal berulang kali.
  • ✓Saat saya membutuhkan Python untuk membuat spreadsheet, dokumen, atau file data.
  • ✓Saat helper agent tidak mampu menjalankan kode Python dengan benar.

Link skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-python-execution/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/fallback-python-execution/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

“Helper tidak bisa menjalankan skrip Python saya untuk membuat spreadsheet. Tolong simpan skripnya ke file dan jalankan langsung.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

AI menulis kode Python lengkap ke file .py, menjalankannya dengan perintah shell, memeriksa bahwa file yang diharapkan muncul, dan opsional menghapus skrip setelahnya.

Konten teknis (SKILL.md asli)

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

Fallback Python Execution Pattern

When to Use

Use this pattern when:

  • execute_code_sandbox returns unknown errors or fails repeatedly
  • shell_agent cannot successfully execute Python code
  • You need to create files (spreadsheets, documents, data files) via Python
  • Direct delegated approaches prove unreliable in the current environment

Core Technique

Instead of delegating Python execution to agents, use this two-step inline approach:

  1. Write Python code to a .py file using write_file
  2. Execute the file using run_shell with python <script.py>

Step-by-Step Instructions

Step 1: Write Python Code to File

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)

Step 2: Execute via run_shell

Run the script directly:

run_shell
command: python /path/to/script.py

Step 3: Verify and Clean Up

  • Check the output for success/errors
  • Verify the expected files were created
  • Optionally remove the temporary script if no longer needed

Why This Works

This approach is more reliable because:

  • Avoids agent interpretation layers that can introduce errors
  • Provides direct control over execution environment
  • Gives clear error output for debugging
  • Bypasses sandbox delegation issues

Example: Excel File Creation

# 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

Tips

  • Include error handling in your Python code for better debugging
  • Use absolute paths when possible to avoid working directory issues
  • Add print statements to track execution progress
  • Keep scripts self-contained with all imports at the top
  • For complex tasks, break into multiple scripts if needed

Troubleshooting

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
Pertanyaan umum

Mengapa menghindari helper agent?

Panduan ini menyatakan bahwa pendekatan ini menghindari lapisan interpretasi tambahan yang bisa menimbulkan galat.

Apakah skrip bisa dihapus setelahnya?

Bisa. Menghapus skrip sementara adalah langkah akhir yang opsional.

Apa yang sebaiknya diperiksa di akhir?

Keluaran untuk keberhasilan atau galat, dan apakah file yang diharapkan sudah dibuat.

Detail

Deskripsi asli dari pembuat

Reliable Python execution workflow when execute_code_sandbox or shell_agent fail

repo: HKUDS/AgentPilot

Popularitas

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

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa