DOCS/journey/troubleshooting/251002_emotion_circular_reference_fix.md
Claude-51124 22557e7132 docs: 오래된 트러블슈팅 아카이브 및 구조 정리
- 7-8월 초기 구축 문서 12개를 _archive/troubleshooting/2025_07-08_initial_setup/로 이동
- book/300_architecture/390_human_in_the_loop_intent_learning.md를 journey/research/intent_classification/로 이동 (개발 여정 문서)
- 빈 폴더 제거 (journey/assets/*)
2025-11-17 14:06:05 +09:00

1.1 KiB

순환 참조 제거 및 감정 DB 저장 수정

작성일: 2025-10-02 16:06 완료일: 2025-10-02 16:10 커밋: 29c0317

문제

1. 응답 시간 23.6초

  • Gemini API 429 quota 에러 반복
  • EMOTIONS 변수 참조 에러 14회

2. 순환 참조 발견

  • llm_service.py → emotion_llm.py → llm_service.py (순환)
  • emotion_llm.py:137에서 LLMService() 생성
  • generate_response_with_emotion()에서 LLM 재호출

원인

  • emotion_llm.py가 LLM 호출 (계층 위반)
  • 중복 LLM 호출: handler.chat + emotion_llm LLM

해결

emotion_llm.py

  • generate_response_with_emotion() 제거 (100-199줄)
  • save_emotion_to_db() 추가 (DB 저장만)

llm_service.py

  • 감정 분석 → 프롬프트 조절 → LLM 호출 → DB 저장 (86-110줄)
  • 순환 참조 해소: llm_service → emotion_llm (단방향)

결과

  • 응답 시간: 23.6초 → 1.9초
  • 감정 DB 저장 정상 작동
  • 16:06:32 KST: surprise 39.53%

교훈

  • 순환 참조는 성능 문제 직결
  • 계층 원칙 준수: LLM 호출은 llm_service만
  • emotion_llm은 분석 + DB 저장만