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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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_sandboxreturns 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
Use descriptive filenames - Name files after their purpose (e.g.,
generate_report.py,process_spreadsheet.py)Set appropriate timeouts - Complex operations may need 60+ seconds
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}") raiseClean up temporary files - After successful execution, you may remove the
.pyfile if not neededCheck dependencies - Ensure required packages (pandas, openpyxl, etc.) are available in the shell environment
Why This Works
run_shellexecutes 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
자주 묻는 질문
실패한 코드가 저장되지 않았다면 어떻게 하나요?
스킬은 파일을 쓰기 전에 시도한 내용을 바탕으로 코드를 다시 만들라고 안내합니다.
제한 시간은 얼마나 줘야 하나요?
스킬의 예시는 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.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.