code-execution-fallback-e81068
하는 일
이 스킬은 AI에게 샌드박스가 알 수 없거나 멈춘 오류를 낼 때 Python을 실행하는 대체 방법을 줍니다. 결과를 내야 하는 코드에 작업이 의존하는 사람을 위한 것입니다.
사용하는 경우
- ✓코드 샌드박스가 알 수 없는 오류를 연속 두 번 낼 때.
- ✓명확한 이유 없이 코드 실행이 멈추거나 시간 초과될 때.
- ✓나중에 확인할 수 있도록 자체 포함된 스크립트를 파일로 저장하고 싶은 경우.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/code-execution-fallback-e81068/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“샌드박스가 제 계산에서 계속 알 수 없는 오류를 냅니다. 스크립트 파일에 넣고 그것을 실행해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 코드를 Python 파일로 저장하고, 명령줄에서 실행하고, 출력된 결과를 확인합니다. 결과는 나중에 쓸 수 있도록 파일에도 저장할 수 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Code Execution Fallback Workflow
When to Use
Use this skill when execute_code_sandbox fails repeatedly (2+ attempts) with unknown, persistent, or unexplained errors. This fallback approach uses write_file + run_shell to save Python scripts to disk and execute them via command line, which has proven more reliable in certain failure scenarios.
Step-by-Step Instructions
Step 1: Detect Repeated Failures
Monitor execute_code_sandbox attempts. After 2 consecutive failures with errors like:
- "Unknown error"
- Timeout errors
- Unexplained execution failures
- Sandbox environment issues
Switch to the fallback workflow immediately.
Step 2: Write the Python Script to File
Use write_file to save your Python code as a .py file in the working directory:
write_file(
path="script.py",
content="""
import sys
import json
# Your Python code here
def main():
# Your logic
result = {"status": "success", "data": "example"}
print(json.dumps(result))
if __name__ == "__main__":
main()
"""
)
Tips:
- Use clear, self-contained code that doesn't rely on sandbox-specific paths
- Include error handling and informative print statements
- Save output to files if needed for later retrieval
Step 3: Execute via Shell
Use run_shell to execute the Python script via command line:
run_shell(
command="python3 script.py",
timeout=60 # Adjust timeout as needed
)
Alternative commands:
python script.py- if python3 alias isn't availablepython3 -u script.py- for unbuffered outputpython3 script.py arg1 arg2- with arguments
Step 4: Verify Output and Results
Check the stdout/stderr from run_shell to:
- Confirm execution succeeded (exit code 0)
- Inspect printed output or results
- Identify any new errors (different from sandbox errors)
If the script writes output files, use read_file to retrieve results.
Step 5: Clean Up (Optional)
Remove temporary script files if they won't be reused:
run_shell(command="rm script.py")
Complete Example
Scenario: execute_code_sandbox failed twice while trying to process data.
Fallback execution:
# Step 1: Write the processing script
write_file(
path="process_data.py",
content="""
import pandas as pd
import json
def process():
data = [1, 2, 3, 4, 5]
result = {"sum": sum(data), "count": len(data)}
print(json.dumps(result))
# Also save to file for reliability
with open("result.json", "w") as f:
json.dump(result, f)
if __name__ == "__main__":
process()
"""
)
# Step 2: Execute via shell
output = run_shell(command="python3 process_data.py")
# Step 3: Read results from file
results = read_file(file_path="result.json", filetype="json")
Troubleshooting
| Issue | Solution |
|---|---|
python3: command not found |
Try python instead, or check available interpreters with which python |
| Permission denied | Ensure the working directory is writable; write_file creates files in workspace by default |
| Module not found | Install dependencies via run_shell(command="pip install package_name") before execution |
| Script hangs | Increase timeout parameter in run_shell |
| Output too long | Redirect output to file within the script and read it separately |
Best Practices
- Always include error handling in scripts to capture failures gracefully
- Write results to files in addition to printing, for reliable retrieval
- Use descriptive filenames to avoid conflicts (e.g.,
task_specific_script.py) - Keep scripts self-contained - avoid dependencies on sandbox environment variables
- Log execution details for debugging:
print(f"Step X complete: {value}")
When NOT to Use This Fallback
- When sandbox isolation is required for security
- When the task explicitly requires
execute_code_sandbox - When
execute_code_sandboxsucceeds consistently (no need to add complexity) - When working with sensitive data that shouldn't persist to disk
자주 묻는 질문
어떤 코드가 파일에 적합한가요?
오류 처리와 명확한 출력 메시지를 갖춘 자체 포함형 코드를 권장합니다.
스크립트는 어디에 저장되나요?
작업 폴더의 파일로 쓰여서, 샌드박스 경로에 의존하지 않습니다.
출력도 저장할 수 있나요?
네. 안내서에 따르면 나중에 가져올 수 있도록 결과를 파일에 쓸 수 있습니다.
상세 정보
작성자의 원본 설명
Fallback workflow for executing Python code when execute_code_sandbox fails repeatedly
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12846
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.