debug-sandbox-execution
하는 일
이 스킬은 모호하거나 부분적인 오류로 실패하는 Python 코드 실행을 디버깅하는 방법입니다. 어느 단계가 깨졌는지 찾고 코드를 다시 작동시켜야 하는 사람을 위한 것입니다.
사용하는 경우
- ✓코드 실행이 알 수 없는 오류로 실패하거나 출력이 불완전하게 멈출 때.
- ✓스크립트가 여러 파일을 만들었는데 일부만 나타나는 경우.
- ✓실패 단계를 찾기 위해 스크립트의 각 부분을 따로 테스트하고 싶을 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/debug-sandbox-execution/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 Python 스크립트가 명확한 오류 없이 중간에 멈춥니다. 어느 부분이 실패하는지 찾아 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 스크립트를 다시 실행해 실패 전까지 나온 출력을 캡처하고, 각 함수를 따로 테스트한 다음, 결과를 차례로 확인해서 원인을 찾습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Debug Sandbox Execution Failures
When execute_code_sandbox fails with unknown errors or incomplete output, use this debugging pattern to identify the root cause and recover incrementally.
Problem
The execute_code_sandbox tool may fail silently, truncate output, or produce opaque errors. Complex scripts with multiple file outputs are especially prone to partial failures.
Solution
Use a three-phase debugging approach:
Phase 1: Capture Partial Execution Traces
When a sandbox execution fails, rerun the code using run_shell with output piping to capture whatever output is produced before the failure:
python your_script.py 2>&1 | head -100
This reveals:
- Which functions/steps executed successfully
- Where the failure occurred
- Any error messages that were suppressed
Phase 2: Isolate Failing Functions
Break the script into smaller, testable units. Execute each function or code block independently:
# Test individual components
if __name__ == "__main__":
# Step 1: Test imports
import numpy as np
print("Imports OK")
# Step 2: Test function A in isolation
result_a = function_a()
print(f"Function A: {result_a}")
# Step 3: Test function B
result_b = function_b(result_a)
print(f"Function B: {result_b}")
Run each section with execute_code_sandbox separately to identify which component fails.
Phase 3: Incremental Output Generation
Generate output files one at a time, verifying each before proceeding:
import numpy as np
import soundfile as sf
# Generate and save file 1
audio1 = np.random.randn(48000 * 10).astype(np.float32)
sf.write('output_01.wav', audio1, 48000, subtype='FLOAT')
# Verify file 1 exists and has expected properties
import os
assert os.path.exists('output_01.wav'), "File 1 not created"
# Generate and save file 2
audio2 = np.random.randn(48000 * 10).astype(np.float32)
sf.write('output_02.wav', audio2, 48000, subtype='FLOAT')
# Verify file 2
assert os.path.exists('output_02.wav'), "File 2 not created"
Example Workflow
- Initial attempt: Run full script with
execute_code_sandbox - On failure: Rerun with
run_shelland| head -100to see partial output - Identify breakpoint: Find the last successful operation
- Split script: Create separate scripts for each major section
- Test incrementally: Run each section, verify outputs, proceed to next
- Combine successful sections: Once all pieces work, combine into final script
Best Practices
- Always verify file creation immediately after writing:
assert os.path.exists(path) - Check file properties (size, duration, format) before assuming success
- Use print statements liberally to mark progress through the script
- Save intermediate outputs so failures don't require restarting from scratch
- Test audio/video generation with short samples first (1-2 seconds) before full-length content
When to Use
- Complex scripts with multiple file outputs
- Audio/video generation pipelines
- Scripts with external library dependencies
- Any
execute_code_sandboxcall that produces incomplete or no output
자주 묻는 질문
왜 부분 출력을 캡처하나요?
어떤 단계가 성공했고 실패가 어디서 일어났는지 보여 주기 때문입니다.
스킬이 코드를 직접 고치나요?
주로 원인을 찾고 단계별로 복구하며, 고치는 것은 찾은 내용에서 이어집니다.
어떤 명령을 쓰나요?
결과를 캡처하기 위해 셸 출력 파이프를 쓰고, 코드 블록마다 별도 테스트 실행을 씁니다.
상세 정보
작성자의 원본 설명
Debug Python code execution failures by capturing partial traces, isolating failing functions, and incrementally verifying outputs
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12850
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.