ElGraph.Nodes.Summarize (ElGraph v0.3.0)

Copy Markdown View Source

컨텍스트 압축 노드 (SPEC §4, M4). 긴 대화의 오래된 메시지를 LLM 요약으로 치환한다.

그래프 노드로 끼운다 (보통 agent 직전):

|> ElGraph.add_node(:compact,
     {ElGraph.Nodes.Summarize, :run, [[
       llm: {ElGraph.LLM.OpenAI, api_key: key},
       trigger: {:messages, 20},   # messages가 20개 초과면 압축
       keep: {:messages, 6},        # 최근 6개는 원문 유지
       store: {Store.ETS, store_config, ["conversations", "c1"]}  # 축출분 보관(선택)
     ]]})

:messages 채널이 ElGraph.Reducers.append reducer일 때 동작한다(노드가 {:replace, list} 마커로 채널을 치환한다). living summary: [요약 메시지 | 최근 N개].