โ† Back to list
eco2-team

chat-agent-persistence

by eco2-team

๐ŸŒฑ ์ด์ฝ”์—์ฝ”(Ecoยฒ) BE

โญ 0๐Ÿด 0๐Ÿ“… Jan 25, 2026

SKILL.md


name: chat-agent-persistence description: Chat ์„œ๋น„์Šค์˜ ์˜์†ํ™” ๋ ˆ์ด์–ด ๊ฐ€์ด๋“œ. Checkpointer(๋ฉ€ํ‹ฐํ„ด ์ปจํ…์ŠคํŠธ), Message Persistence(PostgreSQL), Redis Streams Consumer ์•„ํ‚คํ…์ฒ˜ ๋ฐ ํŠธ๋Ÿฌ๋ธ”์ŠˆํŒ…. Use when: (1) chat.messages ํ…Œ์ด๋ธ”์ด ๋น„์–ด์žˆ์„ ๋•Œ, (2) checkpointer ๊ด€๋ จ ์—๋Ÿฌ ๋ฐœ์ƒ ์‹œ, (3) ๋ฉ€ํ‹ฐํ„ด ๋Œ€ํ™” ์ปจํ…์ŠคํŠธ๊ฐ€ ์œ ์ง€๋˜์ง€ ์•Š์„ ๋•Œ, (4) Redis Streams consumer group ์„ค์ • ์‹œ.

Chat Agent Persistence Guide

Chat ์„œ๋น„์Šค์˜ ๋ฐ์ดํ„ฐ ์˜์†ํ™” ๋ ˆ์ด์–ด (Checkpointer + Message Storage)

Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Chat Persistence Architecture                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                                          โ”‚
โ”‚  โ”‚ chat-worker โ”‚                                                          โ”‚
โ”‚  โ”‚ (LangGraph) โ”‚                                                          โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                                          โ”‚
โ”‚         โ”‚                                                                  โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”                                                            โ”‚
โ”‚    โ”‚         โ”‚                                                            โ”‚
โ”‚    โ–ผ         โ–ผ                                                            โ”‚
โ”‚  Checkpointer    Progress Events                                          โ”‚
โ”‚  (Multi-turn)    (Stage updates)                                          โ”‚
โ”‚    โ”‚                  โ”‚                                                   โ”‚
โ”‚    โ”‚                  โ”‚ XADD                                              โ”‚
โ”‚    โ–ผ                  โ–ผ                                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                    โ”‚
โ”‚  โ”‚ PostgreSQL โ”‚  โ”‚  Redis Streams   โ”‚                                    โ”‚
โ”‚  โ”‚checkpoints โ”‚  โ”‚ chat:events:{0-3}โ”‚                                    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                    โ”‚
โ”‚                           โ”‚                                               โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                 โ”‚
โ”‚              โ”‚            โ”‚            โ”‚                                 โ”‚
โ”‚              โ–ผ            โ–ผ            โ–ผ                                 โ”‚
โ”‚      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚      โ”‚ eventrouter โ”‚ โ”‚chat-persist โ”‚ โ”‚  (other groups)  โ”‚              โ”‚
โ”‚      โ”‚   (group)   โ”‚ โ”‚  (group)    โ”‚ โ”‚                  โ”‚              โ”‚
โ”‚      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚             โ”‚               โ”‚                                           โ”‚
โ”‚             โ–ผ               โ–ผ                                           โ”‚
โ”‚      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                  โ”‚
โ”‚      โ”‚event-router โ”‚ โ”‚chat-consumer โ”‚                                  โ”‚
โ”‚      โ”‚  (SSE fan)  โ”‚ โ”‚  (DB write)  โ”‚                                  โ”‚
โ”‚      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                  โ”‚
โ”‚                             โ”‚                                           โ”‚
โ”‚                             โ–ผ                                           โ”‚
โ”‚                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                  โ”‚
โ”‚                      โ”‚  PostgreSQL  โ”‚                                  โ”‚
โ”‚                      โ”‚chat.messages โ”‚                                  โ”‚
โ”‚                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                  โ”‚
โ”‚                                                                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Two Persistence Paths

PathPurposeComponentTarget
Checkpointer๋ฉ€ํ‹ฐํ„ด ์ปจํ…์ŠคํŠธ (LangGraph state)CachedPostgresSavercheckpoints ํ…Œ์ด๋ธ”
Message Storage๋Œ€ํ™” ์ด๋ ฅ (user/assistant)ChatPersistenceConsumerchat.messages ํ…Œ์ด๋ธ”

Quick Diagnosis

# 1. chat.messages ํ…Œ์ด๋ธ” ํ™•์ธ
kubectl exec -n postgres deploy/postgresql -- psql -U sesacthon -d ecoeco -c \
  "SELECT COUNT(*) FROM chat.messages;"

# 2. Checkpointer ์ƒํƒœ ํ™•์ธ (worker ๋กœ๊ทธ)
kubectl logs -n chat deploy/chat-worker --tail=100 | grep -E "(CachedPostgresSaver|checkpointer|InMemory)"

# 3. Redis Streams consumer group ํ™•์ธ
kubectl exec -n redis rfr-streams-redis-0 -c redis -- redis-cli XINFO GROUPS chat:events:0

Common Issues

Issue 1: CachedPostgresSaver ์ดˆ๊ธฐํ™” ์‹คํŒจ

์ฆ์ƒ: InMemory checkpointer created (Redis fallback disabled)

๋กœ๊ทธ:

[WARNING] CachedPostgresSaver failed, falling back to Redis only:
object _AsyncGeneratorContextManager can't be used in 'await' expression

์›์ธ: checkpointer.py:228์—์„œ async context manager๋ฅผ await๋กœ ํ˜ธ์ถœ

์ƒ์„ธ: See checkpointer.md

Issue 2: chat.messages ํ…Œ์ด๋ธ” ๋น„์–ด์žˆ์Œ

์ฆ์ƒ: chat.conversations์— ๋ฐ์ดํ„ฐ ์žˆ์ง€๋งŒ chat.messages๋Š” 0๊ฑด

์ง„๋‹จ:

# Consumer group ํ™•์ธ - "chat-persistence" ์—†์œผ๋ฉด ๋ฏธ๋ฐฐํฌ
kubectl exec -n redis rfr-streams-redis-0 -c redis -- redis-cli XINFO GROUPS chat:events:0

์›์ธ: ChatPersistenceConsumer ๋ฏธ๋ฐฐํฌ

์ƒ์„ธ: See message-consumer.md

Code Locations

ComponentPath
Checkpointerapps/chat_worker/infrastructure/orchestration/langgraph/checkpointer.py
Dependenciesapps/chat_worker/setup/dependencies.py (Lines 641-678)
Consumer Entryapps/chat/consumer.py
Consumer Infraapps/chat/infrastructure/messaging/redis_streams_consumer.py
Consumer Adapterapps/chat/presentation/consumer/redis_streams_adapter.py

Reference Files

  • Checkpointer ์ƒ์„ธ: See checkpointer.md - Cache-Aside ํŒจํ„ด, LangGraph API
  • Message Consumer ์ƒ์„ธ: See message-consumer.md - ๋ฐฐํฌ ๋ฐฉ๋ฒ•, Consumer Group
  • ํŠธ๋Ÿฌ๋ธ”์ŠˆํŒ… ๋ฌธ์„œ: docs/troubleshooting/chat-messages-not-persisted.md
  • PostgreSQL ๋ถ„์„: docs/reports/postgres-chat-data-analysis.md

Score

Total Score

60/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โœ“LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+10
โ—‹่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

0/10
โ—‹ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

0/15
โ—‹ๆœ€่ฟ‘ใฎๆดปๅ‹•

3ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐใŒใ‚ใ‚‹

0/10
โ—‹ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โœ“่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5
โ—‹ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/5

Reviews

๐Ÿ’ฌ

Reviews coming soon