From 4e8a85c23f4376e741b38c9226bea756e5a4742f Mon Sep 17 00:00:00 2001 From: happybell80 Date: Tue, 14 Oct 2025 22:34:09 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20LangGraph=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20session=20=EC=B2=98=EB=A6=AC=20=EB=B0=8F?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=EB=B6=80=20=EC=97=A3=EC=A7=80=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ColdmailState에서 session 제거 (직렬화 불가) - 각 노드에서 async with aiohttp.ClientSession() 개별 생성 - route_after_filter 함수 추가 - add_conditional_edges로 filter → END or process 분기 - process 노드에서 for 루프로 여러 이메일 처리 - try-except로 IR 실패 시 continue 명시 - 96줄 유지 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../251014_coldmail_ir_analysis_scenario.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/troubleshooting/251014_coldmail_ir_analysis_scenario.md b/troubleshooting/251014_coldmail_ir_analysis_scenario.md index ea34eb4..2c6cc24 100644 --- a/troubleshooting/251014_coldmail_ir_analysis_scenario.md +++ b/troubleshooting/251014_coldmail_ir_analysis_scenario.md @@ -72,19 +72,20 @@ - requirements.txt: langgraph 추가 - app/workflows/__init__.py: 빈 파일 생성 - app/workflows/coldmail_workflow.py 생성: - - from typing import TypedDict; from langgraph.graph import StateGraph, END - - class ColdmailState(TypedDict): emails: list, coldmail_candidates: list, processed_results: list, session: object - - async def fetch_emails_node(state): coldmail_briefing.py:93-121 로직 이동 - - async def filter_coldmail_node(state): coldmail_briefing.py:123-141 로직 이동 - - async def process_email_node(state): coldmail_briefing.py:145-287 for 루프 내용 이동 - - async def send_summary_node(state): coldmail_briefing.py:289-300 로직 이동 + - from typing import TypedDict; from langgraph.graph import StateGraph, END; import aiohttp + - class ColdmailState(TypedDict): emails: list, coldmail_candidates: list, processed_results: list + - async def fetch_emails_node(state): async with aiohttp.ClientSession() as session 내부에서 coldmail_briefing.py:103-121 로직 실행, return {"emails": emails} + - async def filter_coldmail_node(state): for email in state["emails"] 반복, coldmail_briefing.py:125-139 필터 로직, return {"coldmail_candidates": candidates} + - async def process_email_node(state): async with aiohttp.ClientSession() as session 내부에서 for email in state["coldmail_candidates"] 반복, coldmail_briefing.py:145-287 처리, try-except로 IR 실패 시 continue, return {"processed_results": results} + - async def send_summary_node(state): async with aiohttp.ClientSession() as session, coldmail_briefing.py:289-300 요약 전송 + - def route_after_filter(state): return "process" if state["coldmail_candidates"] else END - graph = StateGraph(ColdmailState) - graph.add_node("fetch", fetch_emails_node), add_node("filter", filter_coldmail_node), add_node("process", process_email_node), add_node("send", send_summary_node) - - graph.add_edge("fetch", "filter"), add_edge("filter", "process"), add_edge("process", "send"), add_edge("send", END) + - graph.add_edge("fetch", "filter"), add_conditional_edges("filter", route_after_filter, {"process": "process", END: END}), add_edge("process", "send"), add_edge("send", END) - workflow = graph.compile() -- coldmail_briefing.py:78-302: _run_coldmail_briefing() 전체 교체 +- coldmail_briefing.py:78-302: _run_coldmail_briefing() 교체 - from app.workflows.coldmail_workflow import workflow - - initial_state = {"emails": [], "coldmail_candidates": [], "processed_results": [], "session": session} + - initial_state = {"emails": [], "coldmail_candidates": [], "processed_results": []} - result = await workflow.ainvoke(initial_state) ---