diff --git a/troubleshooting/20250930_fluent_bit_opensearch_issue.md b/troubleshooting/250930_fluent_bit_opensearch_issue.md similarity index 100% rename from troubleshooting/20250930_fluent_bit_opensearch_issue.md rename to troubleshooting/250930_fluent_bit_opensearch_issue.md diff --git a/troubleshooting/20250930_opensearch_hdd_migration.md b/troubleshooting/250930_opensearch_hdd_migration.md similarity index 100% rename from troubleshooting/20250930_opensearch_hdd_migration.md rename to troubleshooting/250930_opensearch_hdd_migration.md diff --git a/troubleshooting/20251002_conversation_log_redesign.md b/troubleshooting/251002_conversation_log_redesign.md similarity index 100% rename from troubleshooting/20251002_conversation_log_redesign.md rename to troubleshooting/251002_conversation_log_redesign.md diff --git a/troubleshooting/20251002_db_separation_emotion_data.md b/troubleshooting/251002_db_separation_emotion_data.md similarity index 100% rename from troubleshooting/20251002_db_separation_emotion_data.md rename to troubleshooting/251002_db_separation_emotion_data.md diff --git a/troubleshooting/20251002_emotion_circular_reference_fix.md b/troubleshooting/251002_emotion_circular_reference_fix.md similarity index 100% rename from troubleshooting/20251002_emotion_circular_reference_fix.md rename to troubleshooting/251002_emotion_circular_reference_fix.md diff --git a/troubleshooting/20251002_emotion_db_storage_fix.md b/troubleshooting/251002_emotion_db_storage_fix.md similarity index 100% rename from troubleshooting/20251002_emotion_db_storage_fix.md rename to troubleshooting/251002_emotion_db_storage_fix.md diff --git a/troubleshooting/20251002_emotion_system_todo.md b/troubleshooting/251002_emotion_system_todo.md similarity index 100% rename from troubleshooting/20251002_emotion_system_todo.md rename to troubleshooting/251002_emotion_system_todo.md diff --git a/troubleshooting/20251002_emotion_top-p_improvement.md b/troubleshooting/251002_emotion_top-p_improvement.md similarity index 100% rename from troubleshooting/20251002_emotion_top-p_improvement.md rename to troubleshooting/251002_emotion_top-p_improvement.md diff --git a/troubleshooting/20251002_file_size_refactoring_plan.md b/troubleshooting/251002_file_size_refactoring_plan.md similarity index 100% rename from troubleshooting/20251002_file_size_refactoring_plan.md rename to troubleshooting/251002_file_size_refactoring_plan.md diff --git a/troubleshooting/20251002_happybell80_slack_bot_and_emotion_errors.md b/troubleshooting/251002_happybell80_slack_bot_and_emotion_errors.md similarity index 100% rename from troubleshooting/20251002_happybell80_slack_bot_and_emotion_errors.md rename to troubleshooting/251002_happybell80_slack_bot_and_emotion_errors.md diff --git a/troubleshooting/20251002_opensearch_cleanup.md b/troubleshooting/251002_opensearch_cleanup.md similarity index 100% rename from troubleshooting/20251002_opensearch_cleanup.md rename to troubleshooting/251002_opensearch_cleanup.md diff --git a/troubleshooting/20251002_rb8001_중복코드_정리.md b/troubleshooting/251002_rb8001_중복코드_정리.md similarity index 100% rename from troubleshooting/20251002_rb8001_중복코드_정리.md rename to troubleshooting/251002_rb8001_중복코드_정리.md diff --git a/troubleshooting/20251004_happybell80_로빙_뇌_기관_원칙_위반_현황.md b/troubleshooting/251004_happybell80_로빙_뇌_기관_원칙_위반_현황.md similarity index 100% rename from troubleshooting/20251004_happybell80_로빙_뇌_기관_원칙_위반_현황.md rename to troubleshooting/251004_happybell80_로빙_뇌_기관_원칙_위반_현황.md diff --git a/troubleshooting/20251010_skill_rag_file_hwp_support.md b/troubleshooting/251010_skill_rag_file_hwp_support.md similarity index 100% rename from troubleshooting/20251010_skill_rag_file_hwp_support.md rename to troubleshooting/251010_skill_rag_file_hwp_support.md diff --git a/troubleshooting/251013_naverworks_briefing_2stage.md b/troubleshooting/251013_naverworks_briefing_2stage.md new file mode 100644 index 0000000..c053047 --- /dev/null +++ b/troubleshooting/251013_naverworks_briefing_2stage.md @@ -0,0 +1,90 @@ +# 네이버웍스 메일 브리핑 2단계 구조 개선 + +**날짜**: 2025-10-13 +**작성자**: happybell80 +**관련 파일**: `rb8001/app/skills/naverworks_briefing.py` + +--- + +## 문제 상황 + +### 현재 구조 (OR 로직) +- `naverworks_briefing.py:58-63` - 중요 메일 필터링 후 없으면 전체 메일로 폴백 +- 중요 메일이 1건이라도 있으면 **전체 메일 요약은 표시 안됨** +- 중요 메일이 없을 때만 전체 메일 요약 표시 + +### 요구사항 +사용자가 원하는 것은 **중요 메일 + 전체 메일 동시 표시 (AND 로직)**: +1. 중요 메일 섹션: 긴급/계약/결제/공지 필터링 결과 +2. 전체 메일 섹션: 72시간(월요일) 또는 24시간(평일) 전체 메일 요약 + +--- + +## 해결 방안 + +### 1. process_briefing() 메인 로직 변경 (58-71줄) + +**수정 내용:** +- 58-63줄: 폴백 로직(`if not important_emails`) 제거 +- 66줄: `_generate_summary()` 호출을 2번으로 분리 + - `important_summary = await self._generate_summary(important_emails, is_important=True)` + - `all_summary = await self._generate_summary(emails, is_important=False)` +- 71줄: `_format_slack_message()` 호출 파라미터 변경 + - 기존: `(summary, important_emails)` + - 변경: `(important_summary, len(important_emails), all_summary, len(emails))` + +### 2. _generate_summary() 시그니처 및 프롬프트 변경 (135줄, 159-174줄) + +**시그니처 변경:** +- 135줄: `async def _generate_summary(self, emails: List[Dict], is_important: bool = False) -> str:` + +**프롬프트 변경 (159-174줄):** +- `is_important=True`: "긴급/계약/결제 등 즉시 확인 필요한 중요 메일 요약" 강조 +- `is_important=False`: "전체 수신 메일 간단 요약, 발신자/주제별 정리" +- 기존 165-167줄 프롬프트를 `is_important` 분기로 변경 + +### 3. _format_slack_message() 시그니처 및 blocks 변경 (190줄, 194-231줄) + +**시그니처 변경 (190줄):** +- `def _format_slack_message(self, important_summary: str, important_count: int, all_summary: str, all_count: int) -> Dict[str, Any]:` + +**blocks 구조 변경 (194-231줄):** +- 기존 215-220줄 section을 2개로 분리: + 1. 중요 메일 섹션: `important_summary` (N건) + 2. 전체 메일 섹션: `all_summary` (M건) +- 두 섹션 사이 divider 추가 +- 222-227줄 context: "중요 메일 N건, 전체 M건" 표시 + +--- + +## 수정 위치 요약 + +| 위치 | 변경 내용 | +|------|----------| +| `naverworks_briefing.py:58-68` | 폴백 제거, 요약 2번 생성 | +| `naverworks_briefing.py:229` | 함수 시그니처 변경 (파라미터 4개) | +| `naverworks_briefing.py:233-270` | blocks 구조 2단계로 분리 | + +--- + +## 교훈 + +### 설계 단계에서 명확한 요구사항 정의 필요 +- "중요 메일만" vs "중요 메일 + 전체 메일" 구분이 초기 설계에서 모호했음 +- OR 로직을 AND 로직으로 전환하려면 요약 생성 비용 2배 발생 (Gemini API 호출 2회) +- 비용/성능 고려 없이 UX만 고려하면 나중에 문제 발생 가능 + +### 폴백 로직의 함정 +- "없으면 전체 사용"은 간단해 보이지만, 실제로는 "둘 중 하나만 보여줌" +- 사용자는 "두 가지를 다른 관점으로 동시에 보고 싶음"을 명시적으로 요청해야 했음 + +### 프롬프트 엔지니어링 +- 중요 메일 요약 프롬프트: "즉시 확인 필요한 사항 강조" +- 전체 메일 요약 프롬프트: "발신자/주제별 간단 요약" +- 같은 `_generate_summary()` 함수를 사용하되, 프롬프트 템플릿 파라미터 추가 필요 + +### 파일 크기 관리 +- 현재 `naverworks_briefing.py`가 301줄로 FastAPI 300줄 한도 초과 +- 제안 반영 시 추가 10-20줄 증가로 320줄 예상 +- 포맷팅 로직(`_format_slack_message`)을 별도 모듈 분리 검토 필요 +- 또는 요약 생성 로직을 서비스 계층 모듈로 분리 고려 diff --git a/troubleshooting/20251013_oauth_jsonb_multi_provider.md b/troubleshooting/251013_oauth_jsonb_multi_provider.md similarity index 100% rename from troubleshooting/20251013_oauth_jsonb_multi_provider.md rename to troubleshooting/251013_oauth_jsonb_multi_provider.md