Vấn Đề Với Chains
LangChain chains là DAG (Directed Acyclic Graph) đơn giản - chỉ đi một chiều và không quay lại.
Limitations:
- Không thể retry bước B nếu C fail
- Không có branching logic phức tạp
- Không support human-in-the-loop interrupts
LangGraph: Cyclic State Machines
LangGraph cho phép:
- Cycles: Agent có thể quay lại bước trước
- Conditional Edges: Rẽ nhánh dựa trên output
- State Persistence: Lưu và restore state bất kỳ lúc nào
So Sánh Chi Tiết
| Feature | LangChain | LangGraph |
|---|---|---|
| Cycles | ❌ | ✅ |
| State Persistence | ⚠️ Memory class | ✅ Built-in |
| Human-in-the-loop | ❌ Phức tạp | ✅ interrupt_before |
| Streaming | ⚠️ | ✅ Node-by-node |
Production Use Cases
- Customer Support Bot: Loop cho đến khi user satisfied
- Code Review Agent: Loop giữa review → fix → re-review
- Research Agent: Loop qua nhiều sources rồi synthesize
💡 LangGraph là evolution của LangChain, không phải replacement.
