본문으로 건너뛰기
Skillpedia
일반 코딩7.8k · #12882

fallback-python-execution

하는 일

이 스킬은 샌드박스나 도우미 에이전트가 Python을 실행하지 못할 때 쓰는 예비 방법입니다. 데이터나 문서 파일을 만들기 위해 Python이 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓샌드박스가 알 수 없는 오류를 내거나 계속 실패할 때.
  • ✓스프레드시트, 문서 또는 데이터 파일을 Python으로 만들어야 할 때.
  • ✓도우미 에이전트가 Python 코드를 올바르게 실행하지 못한 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-python-execution/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“도우미가 스프레드시트를 만드는 Python 스크립트를 실행하지 못합니다. 스크립트를 파일로 저장해서 직접 실행해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 전체 Python 코드를 .py 파일로 쓰고, 셸 명령으로 실행한 뒤 예상한 파일이 나타났는지 확인하고, 원하면 나중에 스크립트를 삭제합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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
자주 묻는 질문

도우미 에이전트를 피하는 이유는 무엇인가요?

가이드는 이 방법이 오류를 만들 수 있는 추가 해석 단계를 피한다고 설명합니다.

나중에 스크립트를 삭제할 수 있나요?

네, 임시 스크립트를 지우는 것은 선택 사항인 마지막 단계입니다.

마지막에 무엇을 확인해야 하나요?

성공 또는 오류 출력과, 예상한 파일이 만들어졌는지를 확인해야 합니다.

상세 정보

작성자의 원본 설명

Reliable Python execution workflow when execute_code_sandbox or shell_agent fail

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12882
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬