본문으로 건너뛰기
Skillpedia
테스트7.8k · #12850

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

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

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

  1. Initial attempt: Run full script with execute_code_sandbox
  2. On failure: Rerun with run_shell and | head -100 to see partial output
  3. Identify breakpoint: Find the last successful operation
  4. Split script: Create separate scripts for each major section
  5. Test incrementally: Run each section, verify outputs, proceed to next
  6. 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_sandbox call 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.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬