Skip to content

fix(eval): judge 호출 무한 대기 방지 (SDK 재시도 OFF + connect/read 타임아웃)#67

Merged
TaskerJang merged 1 commit into
feat/p1-extractor-hardeningfrom
fix/judge-timeout-retry
May 30, 2026
Merged

fix(eval): judge 호출 무한 대기 방지 (SDK 재시도 OFF + connect/read 타임아웃)#67
TaskerJang merged 1 commit into
feat/p1-extractor-hardeningfrom
fix/judge-timeout-retry

Conversation

@TaskerJang

Copy link
Copy Markdown
Owner

배경

#61 80 QA 재측정이 1번 문항(hanwha_001) judge 호출에서 멈춰 Ctrl+C(KeyboardInterrupt)로 죽음. 트레이스백:

faithfulness_judge.py:117 _call_api
  → _active_judge_client.chat.completions.create(...)
  → httpx ... response.read() → _receive_response_body → sock.recv  # 여기서 행
KeyboardInterrupt

기존에도 timeout=60 + tenacity 재시도(3회)는 있었으나:

  • OpenAI SDK 자체 재시도(기본 max_retries=2)가 tenacity(3회)와 곱해짐 → 최악 6회 × 60s ≈ 6분간 멈춘 것처럼 보임.
  • connect 타임아웃 분리 없음 → 연결 단계 stall도 60s 통으로 대기.

변경

  • _make_judge_client(api_key, base_url) 헬퍼 추가 — 모든 judge 클라이언트를 동일 정책으로 생성:
    • timeout=httpx.Timeout(60.0, connect=10.0) — connect 10s / read·write·pool 60s.
    • max_retries=0SDK 자체 재시도 OFF, tenacity 가 유일한 재시도 주체.
  • 모듈 기본 client / _active_judge_client / configure_judge_llm 전부 이 헬퍼 경유.
  • _call_api 의 per-call timeout_JUDGE_TIMEOUT 로 명시(connect 10/read 60 유지).

효과

  • 타임아웃이 곧바로 tenacity 로 전파 → 3회만(지수 백오프 2~8s) 재시도, 최악 대기 ~3.5분으로 축소. 일시적 지연은 보통 2번째 시도에서 해소.
  • 연결 stall은 10s 만에 실패 → 빠른 재시도.
  • API 동작·프롬프트·스키마 fallback 로직 변경 없음(타임아웃/재시도 정책만).

비고

  • 같은 패턴(LLM judge per-QA)인 eval/metrics/answer_correctness.py 와 답변 생성 클라이언트(agent/llm_client)도 동일 보강이 필요할 수 있음 — 후속에서 검토.

측정이 첫 문항 judge 호출에서 멈춰(httpx 응답 본문 read 행) KeyboardInterrupt
로 죽는 문제. 기존에도 timeout=60 + tenacity 재시도는 있었으나, OpenAI SDK
자체 재시도(기본 max_retries=2)가 tenacity 재시도(3회)와 곱해져 최대 6회×60s
≈ 6분간 멈춘 것처럼 보였음. connect 타임아웃도 따로 없어 연결 stall도 60s 대기.

- _make_judge_client: timeout=httpx.Timeout(60, connect=10), max_retries=0
  로 클라이언트 생성하는 헬퍼 추가. 모듈 기본 client / _active_judge_client /
  configure_judge_llm 모두 이 헬퍼 경유.
- max_retries=0 → 타임아웃이 곧바로 tenacity 로 전파, 3회만 재시도(2~8s 백오프).
- _call_api 의 per-call timeout 도 httpx.Timeout(connect 10/read 60)로 명시.
@TaskerJang TaskerJang merged commit a12143a into feat/p1-extractor-hardening May 30, 2026
TaskerJang added a commit that referenced this pull request May 30, 2026
…d on feat/p1)

feat/chunk-rerank 가 dev 베이스라 eval 인프라(#66/#67/gpt-5.2 토글)가 없던 문제 →
feat/p1-extractor-hardening 위로 rebase. 변경 내용은 동일:

- Cypher: MENTIONS 청크를 12개까지 원문으로 retrieve ([..3]/substring 제거)
- _rank_chunks_by_question: bge-m3 cosine 으로 entity 당 top 3 채택 + 600자 절단
- payload 모양({chunk_id,text,page}) 유지 → 답변 프롬프트 무변경

근거: Sentence-Transformers Retrieve & Re-Rank, MS GraphRAG Local Search.
한계: 답 청크가 해당 entity 의 MENTIONS 집합 안에 있을 때만 동작.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant