답변별 복기 부하 안전밸브를 환경변수로 노출 - #221
Merged
Merged
Conversation
feedback 의 최대 비용 지점은 답변별 복기(코칭)다 — 답변 수만큼 LLM 을 부른다. 이를 막는 두 안전밸브(상한 30, 동시성 5)가 FeedbackConsumer 생성자 기본값으로만 존재하고 runner 가 전달하지도, settings 에 있지도 않았다. 게이트웨이가 429 를 내기 시작해도 코드를 고쳐 재배포하지 않으면 조일 수가 없었다. 같은 성격의 다른 값들(embedding_batch_size·llm_*_timeout_sec·*_rag_timeout_sec· feedback_rag_top_k)은 전부 settings 경유다 — 이 둘만 규약(ai/CLAUDE.md §6.2, "코드에 하드코딩 금지")에서 벗어나 있었다. 기본값은 그대로 두어 동작 변화는 없다. .env.example·docs/environment.md 동기화.
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.
배경 — LLM 호출량 감사
비용·부하 축을 보면서 면접 1회의 LLM 호출을 세어봤다. 세션 종료 시
generate.feedback하나가 동시에 부르는 것:복기가 최대 비용 지점이다. 나머지는 세션 길이와 무관하게 상수인데 이것만 선형으로 늘어난다. 답변마다 RAG 검색(임베딩 1 + 검색 1)까지 동반한다.
문제
그걸 막는 안전밸브 두 개가 조절 불가능했다.
runner.py가 이 둘을 전달하지 않고,settings.py에도 없다. 즉 게이트웨이가 429 를 내기 시작해도 코드를 고쳐 재배포하지 않으면 조일 수 없다.코드의 주석은 목적을 정확히 알고 있다 — "게이트웨이 429/과부하 방지 — 답변별 코칭 호출 동시성을 제한한다." 그런데 정작 운영 중에 쓸 수가 없는 상태였다.
그리고 이건 이 저장소의 규약에서 벗어난 것이기도 하다.
ai/CLAUDE.md §6.2는 "설정은 settings.py + 환경변수로 주입 (코드에 하드코딩 금지)" 이고, 같은 성격의 다른 값은 전부 settings 경유다:embedding_batch_size·embedding_max_retries·llm_pro_timeout_sec·llm_flash_timeout_sec·questions_rag_timeout_sec·followup_rag_timeout_sec·feedback_rag_top_k이 둘만 빠져 있었다.
수정
feedback_coaching_max_answers/feedback_coaching_concurrency를 settings 에 추가하고 runner 가 전달한다. 기본값은 그대로(30/5)라 동작 변화는 없다.테스트
test_runner_wires_coaching_limits_from_settings— runner 가 실제로 settings 값을 넘기는지. 런타임 조립에 의존성이 많아 인스턴스 생성 대신 배선을 고정했고, 공백 정규화로 포맷 변경에 깨지지 않게 했다test_coaching_limits_are_settings_backed— Settings 모델에 필드가 있는지395 tests 통과.
동기화
.env.example·docs/environment.md(프로젝트 체크리스트 항목).이번 감사에서 확인했고 문제없던 것
비용·성능 축은 전반적으로 잘 관리돼 있었다.
feedback.coaching.capped로그도 남긴다EMBEDDING_BATCH_SIZE) + 429 지수 백오프 + 재시도 상한(none)폴백parentMessage지연 로딩도 목록 매핑에서 건드리지 않음