Vấn Đề: Agent Chạy Sai Ở Đâu?
Khi một ReAct agent fail sau 10 iterations, làm sao bạn biết nó sai ở bước nào?
1. Checkpointing in LangGraph
LangGraph cung cấp built-in checkpointing với nhiều backends:
- SQLite cho development
- PostgreSQL cho production
2. Thread-based State Management
Mỗi conversation/session được track bằng thread_id. Điều này cho phép:
- Resume conversation sau khi user quay lại
- Debug state tại bất kỳ thời điểm nào
3. Time Travel: Xem Lại Quá Khứ
Lấy tất cả checkpoints cho một thread và replay từ bất kỳ checkpoint nào:
- Get checkpoint at step N
- Modify state nếu cần
- Resume execution từ đó
4. Debugging Workflow
- User reports bug: Agent gave wrong answer at 3pm
- Find thread: Query by user_id + timestamp
- Load checkpoints: See exact state at each step
- Identify failure: Tool returned error at step 5
- Replay and fix: Update tool logic, replay from step 4
🔥 Log checkpoint_id trong mỗi API response để user support có thể trace lại chính xác conversation state.
