[review] 리뷰에 파일 원본과 read_file 도구 추가 - #21
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🤖 코드 리뷰
리뷰 봇의 핵심 로직을 대폭 변경한 PR입니다. 주요 변경사항은:
-
파일 원본 동봉 기능 추가:
src/review/source.ts를 새로 추가하여 diff와 함께 변경된 파일의 현재 내용을 프롬프트에 포함합니다. 변경 구간 주변을 발췌하여 맥락을 제공합니다. -
read_file도구 루프:requestReview를 에이전트 루프로 변경하여 모델이 필요할 때 추가 파일을 읽을 수 있게 했습니다. 경로 검증, 제외 패턴, 읽기 상한 등을 적용했습니다. -
diff 오독 방지 지침: 시스템 프롬프트에 diff의
+/-가 git의 정렬 결과일 뿐임을 명시하여, 기존 코드를 새로 추가된 것으로 오해하는 오탐을 방지합니다. -
예산 관리 개선:
promptBudgets함수를 추가하여 diff와 원본 간 예산을 동적으로 분배합니다.
전반적으로 PR 목적에 부합하는 변경이며, 검증된 로직과 적절한 에러 처리가 포함되어 있습니다.
지적 사항 없음 — 변경분에서 문제를 찾지 못했다.
모델 darwin-35b-q4_k_m.gguf · 파일 5개 리뷰 · 토큰 27,332 in / 17,688 out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
리뷰 프롬프트에 diff만 실려 있어 모델이 헝크 밖 코드를 볼 수 없었습니다. 맥락을 추측으로 메우게 되어 "diff만 검사하고 다른 파일은 확인하지 않는 것 같다"는 피드백으로 이어졌습니다.
직전 PR
#20에서 실제 오탐이 나왔습니다. 봇이addReaction의content누락을critical로 지적하였으나 원본에는 이미 있었습니다. 블록이 끼어들며 손대지 않은 줄까지+로 찍힌 diff 정렬을 그대로 읽은 결과입니다.변경 사항
변경된 파일의 현재 내용 동봉
src/review/source.ts를 추가하였습니다. 리뷰 대상 파일마다 head 기준 내용을줄번호 | 코드형식으로 싣습니다. 예산 안에 들면 전체를, 넘치면 헝크 주변으로 발췌합니다.read_file도구requestReview를 에이전트 루프로 바꾸었습니다. 모델이read_file을 호출하면 그 파일을 읽어 대화에 실어주고 다시 묻습니다. diff에 없는 파일도 읽을 수 있습니다.모델이 준 경로는 검증합니다.
..로 리포지토리 밖을 가리키거나exclude에 걸리면 거절하고 그 사유를 알려줍니다. 비워 보내면 같은 파일을 반복 요청하기 때문입니다. 읽기 횟수에는 상한을 두었습니다.diff 오독 방지 지침
+/-는 git이 두 판본을 맞춰본 결과라 손대지 않은 줄도+로 찍힌다는 점, 기존 코드에 대한 주장은 diff만으로 근거가 되지 않는다는 점을 명시하였습니다.설정으로
includeSources(기본 활성),maxSourceChars,maxExtraReads를 추가하였습니다.검증
npm run typecheck와npm run build를 통과하였습니다. 테스트가 없어 별도 스크립트로 확인하였습니다.read_file루프 5건 — 원본 동봉, 읽기 후 재질의, 경로 탈출·exclude거절, 상한 도달 시 종료토큰은 이 PR 기준 약 1,900자에서 7,500자로 늘었고,
src전체가 바뀌는 최악의 경우에도 청크는 1개에서 2개로만 증가합니다.남은 확인
게이트웨이가 tool calling을 무시해 템플릿을 직접 주입하는 구조라, 모델이
read_file을 규격대로 호출하는지는 실제 PR로 확인해야 합니다. 호출하지 않아도 원본 동봉만으로 위 오탐은 방지됩니다.