직접 만드는 로컬 AI 에이전트 (파트 3): 코드 고고학자 🔦

발행: (2026년 1월 7일 오후 09:00 GMT+9)
3 min read
원문: Dev.to

Source: Dev.to

개요

Part 2에서는 데이터를 조회했습니다. 이제 코드를 문서화합니다.

아마 legacy_math.py 같은 파일에 주석이 없고 변수 이름이 일반적(x, y, z)일 것입니다. 직접 수정하는 것이 위험하게 느껴질 수 있습니다.

여기에 프라이빗 코드 고고학자가 등장합니다 – 코드를 읽고 이해한 뒤, 로컬에서 전문적인 Google‑스타일 docstring을 추가해 주는 에이전트입니다.

에이전트가 수행하는 작업

  1. 대상 파일을 읽습니다.
  2. 문서화되지 않은 함수를 식별합니다.
  3. 인수와 반환값을 설명하는 Google‑스타일 docstring을 생성합니다.
  4. 논리를 변경하지 않고 새 내용으로 파일을 덮어씁니다.

로컬에서 실행하는 이유

프로프라이어터리 알고리즘을 ChatGPT와 같은 호스팅 서비스에 붙여넣고 싶지 않을 수 있습니다. Goose + Ollama를 사용하면 모든 처리가 SSD에 머무르므로 지적 재산을 비공개로 유지할 수 있습니다.

에이전트 지시사항 (frontmatter)

title: Code Archaeologist
instructions: |
  1. Read the file.
  2. For every function, write a DocString explaining Args & Returns.
  3. Overwrite the file with the new content.
  4. Do NOT change the logic.

이 작업에는 gpt-oss:20b 모델을 사용했습니다. 모델은 일반 변수 이름 사이에 숨겨진 Haversine 공식을 정확히 식별하고 명확한 설명을 추가했습니다.

예시

이전

def f2(lat1, lon1...):
    # implementation omitted
    ...

이후 (에이전트 생성)

def f2(lat1, lon1, lat2, lon2):
    """
    Compute the great‑circle distance between two points on the Earth.

    Args:
        lat1 (float): Latitude of the first point in degrees.
        lon1 (float): Longitude of the first point in degrees.
        lat2 (float): Latitude of the second point in degrees.
        lon2 (float): Longitude of the second point in degrees.

    Returns:
        float: Distance between the two points in meters, calculated using the
        haversine formula.
    """
    # implementation unchanged
    ...

다음 단계

대망의 피날레—Part 4: Handling Sensitive PII Data.

Back to Blog

관련 글

더 보기 »

게시물을 웹앱으로

markdown !게시물용 커버 이미지 (웹앱) https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uplo...