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

code-exec-fallback-266cba

하는 일

이 스킬은 내장 코드 실행기가 계속 실패할 때 AI가 방법을 바꾸도록 합니다. AI 작업에 Python 코드가 성공적으로 실행되어야 하는 사람을 위한 것입니다.

사용하는 경우

  • ✓코드 샌드박스가 불분명한 오류로 두 번 연속 실패할 때.
  • ✓코드 실행이 계속 시간 초과되고 재시도가 도움이 되지 않는 경우.
  • ✓샌드박스 대신 Python 스크립트를 명령줄에서 실행해야 할 때.

스킬 링크

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

AI에게 요청하는 예시

“코드 실행기가 제 데이터 스크립트에서 계속 실패합니다. 다른 방법으로 실행하고 출력을 보여 주세요.”

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

작동 방식

AI는 Python 코드를 파일에 쓰고, 셸 명령으로 실행하고, 출력과 오류를 읽은 뒤, 작동했는지 보고합니다.

기술 내용 (원본 SKILL.md)

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

Code Execution Fallback Pattern

When to Use This Skill

Apply this pattern when you encounter repeated failures with execute_code_sandbox:

  • 2+ consecutive failures with opaque or unknown errors
  • Timeout errors that persist across retry attempts
  • Environment-related errors that don't resolve with code fixes

The Fallback Workflow

Step 1: Detect Repeated Failures

Track execution failures. After 2 consecutive failures with execute_code_sandbox, switch to the fallback approach.

Step 2: Write Script to File

Use write_file to save your Python script:

write_file(
    path="/workspace/script_name.py",
    content="# Your Python code here\nimport sys\n..."
)

Step 3: Execute via Shell

Use run_shell to run the script:

run_shell(
    command="python /workspace/script_name.py",
    timeout=300
)

Step 4: Capture Output

Parse stdout/stderr from run_shell output to verify success or diagnose issues.

Complete Example

# Instead of this (which may fail):
result = execute_code_sandbox(code="import pandas as pd\n...")

# Use this fallback pattern:
script_content = """
import pandas as pd
import sys

try:
    # Your logic here
    df = pd.DataFrame({'col': [1, 2, 3]})
    print(df.to_csv())
    sys.exit(0)
except Exception as e:
    print(f"ERROR: {e}", file=sys.stderr)
    sys.exit(1)
"""

# Write the script
write_file(path="/workspace/my_script.py", content=script_content)

# Execute via shell
result = run_shell(command="python /workspace/my_script.py", timeout=300)

Best Practices

  1. Add error handling in your script - use try/except with sys.exit() codes
  2. Set appropriate timeouts - run_shell default is 30s, increase for heavy operations
  3. Clean up temporary files after execution if needed
  4. Log the fallback trigger - document why you switched approaches
  5. Verify Python availability - Most sandboxes have Python 3.x by default

Why This Works

  • write_file is more reliable for file I/O operations
  • run_shell gives you direct control over execution environment
  • Shell execution bypasses sandbox serialization issues
  • Better error visibility through stdout/stderr streams

When NOT to Use This Pattern

  • First-time execution failures (retry the sandbox first)
  • Simple one-liner code (sandbox is faster)
  • When sandbox errors are clearly code bugs (fix the code instead)
  • Security-sensitive operations requiring sandbox isolation
자주 묻는 질문

무엇이 실패로 간주되나요?

샌드박스에서 반복된 오류, 원인 불명의 오류, 시간 초과가 해당합니다.

오류를 볼 수 있나요?

네. 출력과 오류 메시지를 캡처하므로 AI가 무엇이 잘못되었는지 보고할 수 있습니다.

코드를 왜 파일에 쓰나요?

샌드박스가 반복해서 실패했을 때 이 경로가 작동할 수 있다고 안내서가 말하기 때문입니다.

상세 정보

작성자의 원본 설명

Fallback workflow for reliable code execution when sandbox fails repeatedly

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬