Mục lục (33)Bài này thuộc chuỗi nào?Bạn sẽ xây gì?Mental model: state là lịch sử, thread_id là khóa phân vùngcheckpointer làm gì?Khi nào không nên dùng short-term memory?Chuẩn bị1. Yêu cầu môi trường2. Cấu hình providerProject layoutMã nguồn hoàn chỉnhpyproject.toml.env.examplemain.pylocal_openai_memory_stub.py — test harness tùy chọnChạy chương trìnhCách A — provider thậtCách B — chạy local để kiểm chứng thread isolationKết quả đã kiểm chứngGiải thích các dòng quan trọngInMemorySaver() bật checkpoint cho agentthread_id chọn đúng conversationVì sao số message là 2 rồi 4?Checkpointer không phải long-term memoryLịch sử dài cần chiến lược quản lýTroubleshootingValueError hoặc lỗi thiếu thread_idHai người dùng nhìn thấy cùng lịch sửRestart app thì memory biến mất401, 404, 429 hoặc timeout từ providerKhông muốn gọi provider thậtĐiểm cốt lõiBài tiếp theoNguồn tham khảoBài viếtLangChain Lesson 4: Giữ hội thoại theo thread với short-term memory và InMemorySaverlangchainPythonllmAI Agent