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

code-exec-fallback

하는 일

이 스킬은 내장 실행기가 반복해서 실패할 때 Python 코드를 실행하는 대체 방법입니다. AI의 데이터나 계산 스크립트를 어떻게든 실행해야 하는 사람을 위한 것입니다.

사용하는 경우

  • ✓한도, 시간 초과, 누락된 패키지 때문에 실행기가 두 번 이상 실패할 때.
  • ✓정해진 시간 제한과 함께 데이터 스크립트를 셸에서 실행해야 할 때.
  • ✓AI가 실행 결과를 읽고 오류를 보고하기를 원하는 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/code-exec-fallback/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/code-exec-fallback/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는 스크립트를 파일에 쓰고, python3로 셸에서 실행하며, 설정한 시간까지 기다리고, 출력을 읽습니다. 나중에 파일을 삭제할 수 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Code Execution Fallback

When to Use

Use this pattern when execute_code_sandbox fails repeatedly (typically 2+ attempts) due to environment limitations, timeouts, dependency issues, or sandbox restrictions.

The Pattern

Instead of executing code directly in the sandbox, write the Python script to a file and execute it via shell:

  1. Write the script using write_file
  2. Execute via shell using run_shell with python3 script.py
  3. Clean up (optional) remove the temporary file

Step-by-Step Instructions

Step 1: Write the Python Script

Use write_file to save your Python code:
- Path: Choose a descriptive name (e.g., "process_data.py", "analyze.py")
- Content: Your complete Python script with all imports and logic

Step 2: Execute via Shell

Use run_shell to execute:
- Command: "python3 <script_name>.py"
- Timeout: Set appropriately for your task (default 30s, increase if needed)

Step 3: Handle Output

- Capture stdout/stderr from run_shell
- Parse results as needed
- Optionally delete the script file after execution

Example

# Instead of this (which may fail):
execute_code_sandbox(code="import pandas as pd; df = pd.read_csv('data.csv')...")

# Do this:
write_file(path="analyze.py", content="""
import pandas as pd
import json

df = pd.read_csv('data.csv')
result = df.groupby('category').sum()
print(json.dumps(result.to_dict()))
""")

run_shell(command="python3 analyze.py", timeout=60)

Tips for Success

  1. Include all imports in the script file - the shell environment may differ from the sandbox
  2. Use absolute paths or ensure working directory is correct
  3. Add error handling to your script for better debugging
  4. Increase timeout for long-running operations (default is 30s)
  5. Print structured output (JSON) if you need to parse results
  6. Clean up temporary files after successful execution to avoid clutter

When This Helps

  • Sandbox has missing dependencies
  • Code execution times out in sandbox but would work in shell
  • File I/O operations are restricted in sandbox
  • Need to run external commands or system utilities
  • Complex multi-file projects that need proper file structure
자주 묻는 질문

실행기 대신 파일을 쓰는 이유는 무엇인가요?

안내서는 이 경로가 일부 실패 상황에서 더 안정적이었다고 설명합니다.

기본 시간 제한은 얼마인가요?

기본값은 30초이며, 작업에 더 많은 시간이 필요하면 늘릴 수 있습니다.

스크립트에 특별한 설정이 필요한가요?

스크립트는 모든 import와 로직을 포함해서 스스로 실행되어야 합니다.

상세 정보

작성자의 원본 설명

Fallback pattern for executing Python code when execute_code_sandbox fails

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬