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

sandbox-failure-recovery

하는 일

이 워크플로는 샌드박스 실행이 실패했을 때 코드를 저장하고 셸에서 실행해 AI 에이전트가 복구하도록 돕습니다. 작동했던 코드로 스프레드시트나 다른 결과 파일이 필요한 사람을 위한 것입니다.

사용하는 경우

  • ✓코드 샌드박스가 파일 생성 작업에서 오류를 내거나 시간 초과될 때.
  • ✓이미 작성된 코드로 스프레드시트나 CSV를 만들어야 할 때.
  • ✓여러 번 시도해도 샌드박스 환경이 불안정할 때.

스킬 링크

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

AI에게 요청하는 예시

“샌드박스에서 실패한 코드를 스크립트로 바꿔 실행한 뒤, 만들어진 Excel 파일을 주세요.”

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

작동 방식

에이전트는 쓰기 도구로 실패한 코드를 .py 파일에 저장합니다. 그다음 셸에서 시간 제한을 두고 python3로 실행하고, 출력을 읽어 파일이 만들어졌는지 확인합니다.

기술 내용 (원본 SKILL.md)

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

Sandbox Failure Recovery Workflow

When execute_code_sandbox fails (often due to infrastructure issues, timeouts, or complex dependencies), use this recovery pattern to achieve identical results by writing the code to a file and executing it directly.

When to Use This Skill

  • execute_code_sandbox returns an error or times out
  • The task involves spreadsheet generation (Excel, CSV) or file output
  • You have working Python code that needs to be executed
  • The sandbox environment appears unstable

Step-by-Step Instructions

Step 1: Preserve the Failed Code

When execute_code_sandbox fails, capture the Python code that was attempted. If the code was generated but not saved, reconstruct it from the execution attempt.

Step 2: Write Code to File

Use write_file to save the Python script to a .py file:

write_file with:
- path: "script_name.py" (e.g., "generate_report.py", "process_data.py")
- content: <the full Python code>

Example:

# Content for write_file
import pandas as pd
from openpyxl import Workbook

# Your spreadsheet generation logic here
df = pd.DataFrame({'Revenue': [100, 200, 300]})
df.to_excel('output.xlsx', index=False)

Step 3: Execute via run_shell

Run the saved script using run_shell with Python 3:

run_shell with:
- command: "python3 script_name.py"
- timeout: 60 (or higher for complex operations)

Step 4: Verify Output

Check that the expected output files were created:

list_dir with:
- path: "."

Or read the generated file to confirm correctness:

read_file with:
- file_path: "output.xlsx"
- filetype: "xlsx"

Complete Example

Scenario: Generate an Excel P&L report after sandbox failure.

# Step 1: Write the Python script
write_file:
  path: "generate_pnl_report.py"
  content: |
    import pandas as pd
    from openpyxl import Workbook
    
    # Create revenue data
    data = {
        'Tour Stop': ['London', 'Paris', 'Berlin'],
        'Revenue': [50000, 45000, 38000],
        'Withholding Tax': [5000, 4500, 3800],
        'Expenses': [12000, 11000, 9500]
    }
    df = pd.DataFrame(data)
    df['Net Income'] = df['Revenue'] - df['Withholding Tax'] - df['Expenses']
    
    # Export to Excel
    df.to_excel('pnl_report.xlsx', index=False)
    print("Report generated successfully")

# Step 2: Execute the script
run_shell:
  command: "python3 generate_pnl_report.py"
  timeout: 60

# Step 3: Verify
list_dir:
  path: "."

Best Practices

  1. Use descriptive filenames - Name files after their purpose (e.g., generate_report.py, process_spreadsheet.py)

  2. Set appropriate timeouts - Complex operations may need 60+ seconds

  3. Include error handling in your Python code - Add try/except blocks to capture and report issues:

    try:
        # Your code here
    except Exception as e:
        print(f"Error: {e}")
        raise
    
  4. Clean up temporary files - After successful execution, you may remove the .py file if not needed

  5. Check dependencies - Ensure required packages (pandas, openpyxl, etc.) are available in the shell environment

Why This Works

  • run_shell executes in a more stable environment than the sandbox
  • File-based execution avoids sandbox memory/resource constraints
  • The Python interpreter in the shell has full access to installed packages
  • Output files are written directly to the workspace
<THIS_SKILL_EVOLVED>
자주 묻는 질문

실패한 코드가 저장되지 않았다면 어떻게 하나요?

스킬은 파일을 쓰기 전에 시도한 내용을 바탕으로 코드를 다시 만들라고 안내합니다.

제한 시간은 얼마나 줘야 하나요?

스킬의 예시는 60초를 쓰며, 복잡한 작업에는 더 큰 값을 권합니다.

이렇게 하면 결과가 달라지나요?

스킬은 같은 코드를 파일에서 실행해 동일한 결과를 얻는 것을 목표로 합니다.

상세 정보

작성자의 원본 설명

Recover from execute_code_sandbox failures by writing code to file and executing via run_shell

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬