Phase G 구현 결과 기록

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-26 01:27:47 +09:00
parent a01f7a7f8a
commit af07d247f6

View File

@@ -233,3 +233,39 @@ design_agent가 `"mode": "chat"`을 보내지만, persona_agent의 `UnifiedMessa
| 날짜 | 내용 |
|------|------|
| 2026-03-25 | 초안. Kei API 통신 실패 원인 5개 진단 + 4개 수정 항목 정리. |
| 2026-03-25 | 정밀 검토로 G-5/G-6/G-7 추가. 총 7개 항목. |
| 2026-03-26 | Phase G 전체 구현 완료. 검증 통과. |
## 구현 완료 확인
| 항목 | 검증 결과 |
|------|----------|
| G-1 | 3개 파일 모두 `client.stream("POST")` + `response.aiter_lines()` 전환. 기존 `client.post()` 0건. `_stream_sse_tokens()` 함수로 SSE 실시간 수신. |
| G-2 | kei_client.py: `_call_anthropic_direct()` 호출 제거. content_editor.py: Sonnet fallback 분기 제거. Sonnet 직접 호출 0건. |
| G-3 | content_editor.py + design_director.py의 `_parse_json()`에 마크다운 `- ` 접두사 제거 전처리 추가. "원본 먼저 → 클린 버전" 순서 유지. kei_client.py와 동기화. |
| G-4 | block_search.py + build_block_index.py: `SentenceTransformer(EMBEDDING_MODEL, device="cpu")`. persona_agent GPU 독점 가능. |
| G-5 | 3개 파일의 `_stream_sse_tokens()`에서 `event_type == "error"` 시 로그 + break. 무한 대기 방지. |
| G-6 | content_editor.py: Kei API 실패(`result_text is None`) 시 `_apply_defaults(blocks); continue`. `_parse_json(None)` TypeError 방지. |
| G-7 | 3개 파일의 API 요청 body에서 `"mode": "chat"``"mode_hint": "chat"`. persona_agent의 실제 필드명에 맞춤. |
### 파일별 구현 상세
**kei_client.py:**
- `classify_content()`: Sonnet fallback 6줄 제거. Kei API 실패 → None 반환 → pipeline.py manual_classify() 안전망.
- `_call_kei_api()`: `client.post()``client.stream("POST")` + `_stream_sse_tokens(response)`. `"mode"``"mode_hint"`.
- `_stream_sse_tokens()`: 신규 함수. `aiter_lines()`로 SSE 실시간 수신. token/done/error 처리.
**content_editor.py:**
- `fill_content()`: Sonnet fallback 7줄 제거. `result_text is None``_apply_defaults(blocks); continue`.
- `_call_kei_editor()`: `client.post()``client.stream("POST")` + `_stream_sse_tokens(response)`. `"mode"``"mode_hint"`.
- `_stream_sse_tokens()`: 신규 함수. kei_client.py와 동일 패턴.
- `_parse_json()`: 마크다운 `- ` 접두사 제거 전처리 추가. 원본 먼저 → 클린 버전.
**design_director.py:**
- `_opus_block_recommendation()`: 인라인 SSE 파싱 30줄 → `client.stream("POST")` + `_stream_sse_tokens(response)`. `"mode"``"mode_hint"`.
- `_stream_sse_tokens()`: 신규 함수. 동일 패턴.
- `_parse_json()`: 마크다운 제거 전처리 추가. 원본 먼저 → 클린 버전.
- `import httpx` 모듈 레벨로 이동 (기존 지역 import → `_stream_sse_tokens`에서도 참조 가능).
**block_search.py + build_block_index.py:**
- `SentenceTransformer(EMBEDDING_MODEL)``SentenceTransformer(EMBEDDING_MODEL, device="cpu")`