{"id":90393,"date":"2026-08-05T08:50:12","date_gmt":"2026-08-05T00:50:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/90393.html"},"modified":"2026-08-05T08:50:12","modified_gmt":"2026-08-05T00:50:12","slug":"langgraph-checkpoint-%e5%85%a5%e9%97%a8%ef%bc%9a%e7%94%a8-memorysaver-%e4%b8%ba-agent-%e8%a3%85%e4%b8%8a%e3%80%8c%e5%8f%af%e6%81%a2%e5%a4%8d%e7%9a%84%e8%ae%b0%e5%bf%86%e3%80%8d","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/90393.html","title":{"rendered":"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81%E4%B8%BA%E4%BB%80%E4%B9%88%20Agent%20%E9%9C%80%E8%A6%81%20Checkpoint%EF%BC%9F-toc\" style=\"margin-left:0px\">\u4e00\u3001\u4e3a\u4ec0\u4e48 Agent \u9700\u8981 Checkpoint&#xff1f;<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E5%85%88%E5%BB%BA%E7%AB%8B%E6%AD%A3%E7%A1%AE%E7%9A%84%E5%BF%83%E6%99%BA%E6%A8%A1%E5%9E%8B-toc\" style=\"margin-left:0px\">\u4e8c\u3001\u5148\u5efa\u7acb\u6b63\u786e\u7684\u5fc3\u667a\u6a21\u578b<\/p>\n<p id=\"%E4%B8%89%E3%80%81Checkpoint%E3%80%81Thread%20%E4%B8%8E%E7%89%88%E6%9C%AC%E9%93%BE-toc\" style=\"margin-left:0px\">\u4e09\u3001Checkpoint\u3001Thread \u4e0e\u7248\u672c\u94fe<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89Checkpointer%EF%BC%9A%E7%8A%B6%E6%80%81%E4%BF%9D%E5%AD%98%E5%90%8E%E7%AB%AF-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;Checkpointer&#xff1a;\u72b6\u6001\u4fdd\u5b58\u540e\u7aef<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89Thread%20ID%EF%BC%9A%E4%B8%80%E6%9D%A1%E7%8A%B6%E6%80%81%E9%93%BE%E7%9A%84%E4%B8%9A%E5%8A%A1%E6%A0%87%E8%AF%86-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;Thread ID&#xff1a;\u4e00\u6761\u72b6\u6001\u94fe\u7684\u4e1a\u52a1\u6807\u8bc6<\/p>\n<p id=\"%EF%BC%88%E4%B8%89%EF%BC%89Checkpoint%20%E7%89%88%E6%9C%AC%E9%93%BE%EF%BC%9A%E7%8A%B6%E6%80%81%E4%B8%8D%E5%8F%AA%E6%9C%89%E2%80%9C%E7%8E%B0%E5%9C%A8%E2%80%9D-toc\" style=\"margin-left:40px\">&#xff08;\u4e09&#xff09;Checkpoint \u7248\u672c\u94fe&#xff1a;\u72b6\u6001\u4e0d\u53ea\u6709\u201c\u73b0\u5728\u201d<\/p>\n<p id=\"%EF%BC%88%E5%9B%9B%EF%BC%89%E4%B8%80%E6%AC%A1%20invoke%20%E5%88%B0%E5%BA%95%E5%8F%91%E7%94%9F%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F-toc\" style=\"margin-left:40px\">&#xff08;\u56db&#xff09;\u4e00\u6b21 invoke \u5230\u5e95\u53d1\u751f\u4e86\u4ec0\u4e48&#xff1f;<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E4%BB%A3%E7%A0%81%E6%BC%94%E7%A4%BA%E8%AF%A6%E7%BB%86%E8%AF%B4%E6%98%8E-toc\" style=\"margin-left:0px\">\u56db\u3001\u4ee3\u7801\u6f14\u793a\u8be6\u7ec6\u8bf4\u660e<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;\u4ee3\u7801\u7ed3\u6784\u5206\u6790<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E8%AF%A6%E7%BB%86%E6%BC%94%E7%A4%BA%E8%AF%B4%E6%98%8E%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;\u8be6\u7ec6\u6f14\u793a\u8bf4\u660e\u5206\u6790<\/p>\n<p id=\"1.%20%E6%BC%94%E7%A4%BA%201%EF%BC%9AMemorySaver%20%E5%9F%BA%E6%9C%AC%E7%94%A8%E6%B3%95-toc\" style=\"margin-left:80px\">1. \u6f14\u793a 1&#xff1a;MemorySaver \u57fa\u672c\u7528\u6cd5<\/p>\n<p id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%20turn_count%20%E6%98%AF%201%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%203%EF%BC%9F-toc\" style=\"margin-left:120px\">\u4e3a\u4ec0\u4e48 turn_count \u662f 1&#xff0c;\u800c\u4e0d\u662f 3&#xff1f;<\/p>\n<p id=\"2.%20%E6%BC%94%E7%A4%BA%202%EF%BC%9AThread%20ID%20%E9%9A%94%E7%A6%BB-toc\" style=\"margin-left:80px\">2. \u6f14\u793a 2&#xff1a;Thread ID \u9694\u79bb<\/p>\n<p id=\"%E7%BA%BF%E4%B8%8A%E7%8E%AF%E5%A2%83%E5%BA%94%E8%AF%A5%E5%A6%82%E4%BD%95%E8%AE%BE%E8%AE%A1%20thread_id%EF%BC%9F-toc\" style=\"margin-left:120px\">\u7ebf\u4e0a\u73af\u5883\u5e94\u8be5\u5982\u4f55\u8bbe\u8ba1 thread_id&#xff1f;<\/p>\n<p id=\"3.%20%E6%BC%94%E7%A4%BA%203%EF%BC%9A%E7%8A%B6%E6%80%81%E6%81%A2%E5%A4%8D-toc\" style=\"margin-left:80px\">3. \u6f14\u793a 3&#xff1a;\u72b6\u6001\u6062\u590d<\/p>\n<p id=\"%E4%B8%80%E4%B8%AA%E5%BF%85%E9%A1%BB%E8%AE%B2%E6%B8%85%E6%A5%9A%E7%9A%84%E7%BB%86%E8%8A%82-toc\" style=\"margin-left:120px\">\u4e00\u4e2a\u5fc5\u987b\u8bb2\u6e05\u695a\u7684\u7ec6\u8282<\/p>\n<p id=\"4.%20%E6%BC%94%E7%A4%BA%204%EF%BC%9A%E6%9F%A5%E7%9C%8B%20Checkpoint%20%E5%8E%86%E5%8F%B2-toc\" style=\"margin-left:80px\">4. \u6f14\u793a 4&#xff1a;\u67e5\u770b Checkpoint \u5386\u53f2<\/p>\n<p id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%89%E6%AC%A1%20invoke%20%E4%BC%9A%E6%9C%89%E5%85%AD%E4%B8%AA%E4%BB%A5%E4%B8%8A%E7%9A%84%E7%89%88%E6%9C%AC%EF%BC%9F-toc\" style=\"margin-left:120px\">\u4e3a\u4ec0\u4e48\u4e09\u6b21 invoke \u4f1a\u6709\u516d\u4e2a\u4ee5\u4e0a\u7684\u7248\u672c&#xff1f;<\/p>\n<p id=\"%E5%8E%86%E5%8F%B2%E9%A1%BA%E5%BA%8F%E4%B9%9F%E8%A6%81%E6%B3%A8%E6%84%8F-toc\" style=\"margin-left:120px\">\u5386\u53f2\u987a\u5e8f\u4e5f\u8981\u6ce8\u610f<\/p>\n<p id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E4%BB%8E%E5%8E%86%E5%8F%B2%20Checkpoint%20%E6%81%A2%E5%A4%8D%EF%BC%8C%E4%B8%8D%E7%AD%89%E4%BA%8E%E8%AF%BB%E5%8F%96%E7%BC%93%E5%AD%98-toc\" style=\"margin-left:40px\">&#xff08;\u4e09&#xff09;\u4ece\u5386\u53f2 Checkpoint \u6062\u590d&#xff0c;\u4e0d\u7b49\u4e8e\u8bfb\u53d6\u7f13\u5b58<\/p>\n<p id=\"1.%20%E6%9F%A5%E7%9C%8B%E5%8E%86%E5%8F%B2%E7%8A%B6%E6%80%81-toc\" style=\"margin-left:80px\">1. \u67e5\u770b\u5386\u53f2\u72b6\u6001<\/p>\n<p id=\"2.%20%E4%BB%8E%E5%8E%86%E5%8F%B2%E7%8A%B6%E6%80%81%E9%87%8D%E6%96%B0%E6%89%A7%E8%A1%8C-toc\" style=\"margin-left:80px\">2. \u4ece\u5386\u53f2\u72b6\u6001\u91cd\u65b0\u6267\u884c<\/p>\n<p id=\"%E4%BA%94%E3%80%81Checkpoint%20%E4%B8%8E%20Store%20%E4%B8%8D%E8%A6%81%E6%B7%B7%E4%B8%BA%E4%B8%80%E8%B0%88-toc\" style=\"margin-left:0px\">\u4e94\u3001Checkpoint \u4e0e Store \u4e0d\u8981\u6df7\u4e3a\u4e00\u8c08<\/p>\n<p id=\"%E5%85%AD%E3%80%81%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E8%AF%B4%E6%98%8E%E5%8F%8A%E7%BA%BF%E4%B8%8A%E8%80%83%E8%99%91%E5%9F%BA%E6%9C%AC%E7%82%B9%E8%AF%B4%E6%98%8E-toc\" style=\"margin-left:0px\">\u516d\u3001\u5e38\u89c1\u95ee\u9898\u6392\u67e5\u8bf4\u660e\u53ca\u7ebf\u4e0a\u8003\u8651\u57fa\u672c\u70b9\u8bf4\u660e<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B8%8E%E6%8E%92%E6%9F%A5%E6%96%B9%E5%BC%8F-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;\u5e38\u89c1\u95ee\u9898\u4e0e\u6392\u67e5\u65b9\u5f0f<\/p>\n<p id=\"1.%20%E9%97%AE%E9%A2%98%201%EF%BC%9A%E5%BF%98%E8%AE%B0%E4%BC%A0%E5%85%A5%20thread_id-toc\" style=\"margin-left:80px\">1. \u95ee\u9898 1&#xff1a;\u5fd8\u8bb0\u4f20\u5165 thread_id<\/p>\n<p id=\"2.%20%E9%97%AE%E9%A2%98%202%EF%BC%9A%E6%9C%8D%E5%8A%A1%E9%87%8D%E5%90%AF%E5%90%8E%20MemorySaver%20%E7%8A%B6%E6%80%81%E6%B6%88%E5%A4%B1-toc\" style=\"margin-left:80px\">2. \u95ee\u9898 2&#xff1a;\u670d\u52a1\u91cd\u542f\u540e MemorySaver \u72b6\u6001\u6d88\u5931<\/p>\n<p id=\"3.%20%E9%97%AE%E9%A2%98%203%EF%BC%9A%E4%B8%8D%E5%90%8C%E7%94%A8%E6%88%B7%E7%9A%84%E5%AF%B9%E8%AF%9D%E5%8F%91%E7%94%9F%E4%B8%B2%E5%8F%B0-toc\" style=\"margin-left:80px\">3. \u95ee\u9898 3&#xff1a;\u4e0d\u540c\u7528\u6237\u7684\u5bf9\u8bdd\u53d1\u751f\u4e32\u53f0<\/p>\n<p id=\"4.%20%E9%97%AE%E9%A2%98%204%EF%BC%9A%E6%B6%88%E6%81%AF%E8%83%BD%E5%A4%9F%E7%B4%AF%E7%A7%AF%EF%BC%8C%E6%99%AE%E9%80%9A%E5%AD%97%E6%AE%B5%E5%8D%B4%E6%B2%A1%E6%9C%89%E7%B4%AF%E7%A7%AF-toc\" style=\"margin-left:80px\">4. \u95ee\u9898 4&#xff1a;\u6d88\u606f\u80fd\u591f\u7d2f\u79ef&#xff0c;\u666e\u901a\u5b57\u6bb5\u5374\u6ca1\u6709\u7d2f\u79ef<\/p>\n<p id=\"5.%20%E9%97%AE%E9%A2%98%205%EF%BC%9A%E4%BF%AE%E6%94%B9%20State%20%E5%90%8E%EF%BC%8C%E6%97%A7%20Checkpoint%20%E5%87%BA%E7%8E%B0%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98-toc\" style=\"margin-left:80px\">5. \u95ee\u9898 5&#xff1a;\u4fee\u6539 State \u540e&#xff0c;\u65e7 Checkpoint \u51fa\u73b0\u517c\u5bb9\u95ee\u9898<\/p>\n<p id=\"6.%20%E9%97%AE%E9%A2%98%206%EF%BC%9ACheckpoint%20%E8%B6%8A%E7%A7%AF%E8%B6%8A%E5%A4%9A-toc\" style=\"margin-left:80px\">6. \u95ee\u9898 6&#xff1a;Checkpoint \u8d8a\u79ef\u8d8a\u591a<\/p>\n<p id=\"%E8%A3%81%E5%89%AA%E6%A8%A1%E5%9E%8B%E4%B8%8A%E4%B8%8B%E6%96%87-toc\" style=\"margin-left:120px\">\u88c1\u526a\u6a21\u578b\u4e0a\u4e0b\u6587<\/p>\n<p id=\"%E6%B8%85%E7%90%86%20Checkpoint%20%E5%8E%86%E5%8F%B2-toc\" style=\"margin-left:120px\">\u6e05\u7406 Checkpoint \u5386\u53f2<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E8%BF%98%E9%9C%80%E8%A6%81%E8%80%83%E8%99%91%E4%BB%80%E4%B9%88%EF%BC%9F-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;\u751f\u4ea7\u73af\u5883\u8fd8\u9700\u8981\u8003\u8651\u4ec0\u4e48&#xff1f;<\/p>\n<p id=\"1.%20%E6%8C%81%E4%B9%85%E5%8C%96%E5%90%8E%E7%AB%AF-toc\" style=\"margin-left:80px\">1. \u6301\u4e45\u5316\u540e\u7aef<\/p>\n<p id=\"2.%20%E5%90%8C%E4%B8%80%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%B9%B6%E5%8F%91%E8%B0%83%E7%94%A8-toc\" style=\"margin-left:80px\">2. \u540c\u4e00\u7ebf\u7a0b\u7684\u5e76\u53d1\u8c03\u7528<\/p>\n<p id=\"3.%20%E8%8A%82%E7%82%B9%E5%B9%82%E7%AD%89%E6%80%A7-toc\" style=\"margin-left:80px\">3. \u8282\u70b9\u5e42\u7b49\u6027<\/p>\n<p id=\"4.%20%E6%95%8F%E6%84%9F%E6%95%B0%E6%8D%AE%E4%BF%9D%E6%8A%A4-toc\" style=\"margin-left:80px\">4. \u654f\u611f\u6570\u636e\u4fdd\u62a4<\/p>\n<p id=\"5.%20%E5%8F%AF%E8%A7%82%E6%B5%8B%E6%80%A7-toc\" style=\"margin-left:80px\">5. \u53ef\u89c2\u6d4b\u6027<\/p>\n<p id=\"%E4%B8%83%E3%80%81%E5%A6%82%E4%BD%95%E8%AF%BB%E6%87%82%E6%9C%AC%E6%AC%A1%20Demo%20%E7%9A%84%E5%9B%9B%E4%B8%AA%E7%BB%93%E6%9E%9C%EF%BC%9F-toc\" style=\"margin-left:0px\">\u4e03\u3001\u5982\u4f55\u8bfb\u61c2\u672c\u6b21 Demo \u7684\u56db\u4e2a\u7ed3\u679c&#xff1f;<\/p>\n<p id=\"%E5%85%AB%E3%80%81%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:0px\">\u516b\u3001\u603b\u7ed3<\/p>\n<p id=\"%E4%B8%80%E9%A1%B5%E9%80%9F%E6%9F%A5-toc\" style=\"margin-left:0px\">\u4e00\u9875\u901f\u67e5<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u5e72\u8d27\u5206\u4eab&#xff0c;\u611f\u8c22\u60a8\u7684\u9605\u8bfb&#xff01;<\/p>\n<p>\u8fd9\u662f\u300cLangGraph Agent Engineering Mastery\u300d\u7cfb\u5217 Stage 3\u300c\u8bb0\u5fc6\u300d\u7cfb\u5217\u7b2c 2 \u7bc7\u3002 \u672c\u6587\u5b8c\u6574\u6f14\u793a MemorySaver\u3001thread_id\u3001\u72b6\u6001\u6062\u590d\u548c Checkpoint \u5386\u53f2\u7248\u672c&#xff0c;\u5e76\u91cd\u70b9\u89e3\u91ca\u4e00\u4e2a\u5bb9\u6613\u88ab\u8bef\u89e3\u7684\u95ee\u9898&#xff1a;<span style=\"color:#fe2c24\">\u5185\u5b58 Checkpoint \u80fd\u6062\u590d\u72b6\u6001&#xff0c;\u4f46\u4e0d\u7b49\u4e8e\u771f\u6b63\u7684\u8de8\u8fdb\u7a0b\u6301\u4e45\u5316<\/span>\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1200\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005007-6a7288bf1bd16.png\" width=\"800\" \/><\/p>\n<h2 id=\"%E4%B8%80%E3%80%81%E4%B8%BA%E4%BB%80%E4%B9%88%20Agent%20%E9%9C%80%E8%A6%81%20Checkpoint%EF%BC%9F\" style=\"background-color:transparent\">\u4e00\u3001\u4e3a\u4ec0\u4e48 Agent \u9700\u8981 Checkpoint&#xff1f;<\/h2>\n<p>\u8bbe\u60f3\u8fd9\u6837\u4e00\u4e2a\u573a\u666f\u3002\u7528\u6237\u6b63\u5728\u548c\u4f60\u7684 Agent \u4ea4\u8c08&#xff1a;<\/p>\n<p>\u8bb0\u4f4f&#xff0c;\u6211\u7684\u5bc6\u7801\u63d0\u793a\u662f\u300c\u84dd\u8272\u7684\u5929\u7a7a\u300d\u3002<\/p>\n<p>\u7d27\u63a5\u7740&#xff0c;\u4f60\u53d1\u5e03\u4e86\u65b0\u7248\u672c&#xff0c;\u670d\u52a1\u91cd\u65b0\u90e8\u7f72&#xff0c;\u539f\u6765\u7684 Python \u8fdb\u7a0b\u9000\u51fa\u3002\u51e0\u5206\u949f\u540e&#xff0c;\u7528\u6237\u56de\u6765\u95ee&#xff1a;<\/p>\n<p>\u6211\u7684\u5bc6\u7801\u63d0\u793a\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>Agent \u5374\u56de\u7b54&#xff1a;<\/p>\n<p>\u62b1\u6b49&#xff0c;\u6211\u4eec\u597d\u50cf\u521a\u521a\u5f00\u59cb\u804a\u5929\u3002<\/p>\n<p>\u4ece\u6a21\u578b\u7684\u89d2\u5ea6\u770b&#xff0c;\u8fd9\u4e2a\u56de\u7b54\u5e76\u6ca1\u6709\u9519\u3002\u56e0\u4e3a\u5927\u8bed\u8a00\u6a21\u578b\u672c\u8eab\u4e0d\u4f1a\u81ea\u52a8\u4fdd\u5b58\u4e0a\u4e00\u6b21\u8c03\u7528\u7684\u72b6\u6001&#xff1b;\u5982\u679c\u5e94\u7528\u4e5f\u6ca1\u6709\u5c06\u6d88\u606f\u5386\u53f2\u548c\u6267\u884c\u72b6\u6001\u5b58\u4e0b\u6765&#xff0c;\u90a3\u4e48\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u53ea\u662f\u4e00\u6b21\u5168\u65b0\u7684\u63a8\u7406\u3002<\/p>\n<p>\u95ee\u9898\u7684\u6839\u6e90\u4e0d\u662f\u6a21\u578b\u201c\u8bb0\u6027\u5dee\u201d&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\">Agent \u7684\u72b6\u6001\u9ed8\u8ba4\u53ea\u5b58\u5728\u4e8e\u5f53\u524d\u6267\u884c\u4e0a\u4e0b\u6587\u4e2d\u3002\u5e94\u7528\u4e0d\u4e3b\u52a8\u4fdd\u5b58&#xff0c;\u72b6\u6001\u5c31\u4e0d\u4f1a\u81ea\u52a8\u5ef6\u7eed\u3002<\/span><\/p>\n<p>LangGraph \u7684 Checkpoint \u673a\u5236&#xff0c;\u5c31\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u5b83\u4f1a\u5728 Graph \u6267\u884c\u8fc7\u7a0b\u4e2d\u4fdd\u5b58\u72b6\u6001\u5feb\u7167&#xff0c;\u5e76\u901a\u8fc7\u4e00\u4e2a\u7a33\u5b9a\u7684 thread_id \u5c06\u8fd9\u4e9b\u5feb\u7167\u7ec4\u7ec7\u6210\u72ec\u7acb\u7ebf\u7a0b\u3002\u540e\u7eed\u8bf7\u6c42\u518d\u6b21\u4f7f\u7528\u76f8\u540c\u7684 thread_id \u65f6&#xff0c;Graph \u5c31\u80fd\u591f\u5148\u6062\u590d\u5df2\u6709\u72b6\u6001&#xff0c;\u518d\u7ee7\u7eed\u6267\u884c\u3002<\/p>\n<p>\u5b98\u65b9\u6587\u6863\u5c06 Checkpointer \u5b9a\u4f4d\u4e3a\u7ebf\u7a0b\u8303\u56f4\u5185\u7684\u72b6\u6001\u6301\u4e45\u5316\u673a\u5236&#xff0c;\u4e3b\u8981\u7528\u4e8e\u591a\u8f6e\u5bf9\u8bdd\u3001\u4eba\u5de5\u5ba1\u6279\u3001\u6545\u969c\u6062\u590d\u548c\u65f6\u95f4\u65c5\u884c&#xff1b;\u8de8\u7ebf\u7a0b\u5171\u4eab\u7684\u957f\u671f\u4e8b\u5b9e&#xff0c;\u5219\u66f4\u9002\u5408\u653e\u5165 Store\u3002<\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81%E5%85%88%E5%BB%BA%E7%AB%8B%E6%AD%A3%E7%A1%AE%E7%9A%84%E5%BF%83%E6%99%BA%E6%A8%A1%E5%9E%8B\">\u4e8c\u3001\u5148\u5efa\u7acb\u6b63\u786e\u7684\u5fc3\u667a\u6a21\u578b<\/h2>\n<p>\u5f88\u591a\u4eba\u7b2c\u4e00\u6b21\u770b\u5230 Checkpoint&#xff0c;\u4f1a\u628a\u5b83\u7406\u89e3\u6210\u201c\u81ea\u52a8\u4fdd\u5b58\u804a\u5929\u8bb0\u5f55\u201d\u3002\u8fd9\u4e2a\u7406\u89e3\u4e0d\u7b97\u9519&#xff0c;\u4f46\u8fd8\u4e0d\u591f\u5b8c\u6574\u3002<\/p>\n<p>Checkpoint \u4fdd\u5b58\u7684\u4e0d\u53ea\u662f messages&#xff0c;\u800c\u662f\u5f53\u524d Graph State \u4e2d\u6240\u6709\u53d7\u7ba1\u7406\u7684\u72b6\u6001\u5b57\u6bb5\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p>class ChatState(TypedDict):<br \/>\n    messages: Annotated[list[BaseMessage], add_messages]<br \/>\n    turn_count: int<\/p>\n<p>\u8fd9\u4e2a State \u91cc\u5305\u542b\u4e24\u4e2a\u5b57\u6bb5&#xff1a;<\/p>\n<ul>\n<li>\n<p>messages&#xff1a;\u5b8c\u6574\u7684\u6d88\u606f\u5e8f\u5217&#xff1b;<\/p>\n<\/li>\n<li>\n<p>turn_count&#xff1a;\u5f53\u524d\u8bb0\u5f55\u7684\u5bf9\u8bdd\u8f6e\u6b21\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5982\u679c\u4e00\u4e2a\u66f4\u590d\u6742\u7684 Agent \u8fd8\u4fdd\u5b58\u4e86\u5de5\u5177\u7ed3\u679c\u3001\u5ba1\u6279\u72b6\u6001\u3001\u68c0\u7d22\u6587\u6863\u3001\u6267\u884c\u8ba1\u5212\u3001\u5f85\u5904\u7406\u4efb\u52a1\u6216\u5de5\u4f5c\u6d41\u8fdb\u5ea6&#xff0c;\u8fd9\u4e9b\u5b57\u6bb5\u540c\u6837\u53ef\u4ee5\u6210\u4e3a Checkpoint \u7684\u4e00\u90e8\u5206\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u66f4\u51c6\u786e\u7684\u5b9a\u4e49\u662f&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\"><span style=\"background-color:#fefcd8\">Checkpoint \u662f Graph State \u5728\u67d0\u4e2a\u6267\u884c\u65f6\u523b\u7684\u72b6\u6001\u5feb\u7167\u3002<\/span><\/span><\/p>\n<p>LangGraph \u4f1a\u5728\u6bcf\u4e2a <span style=\"color:#fe2c24\">super-step \u8fb9\u754c<\/span>\u4fdd\u5b58\u5b8c\u6574\u7684 StateSnapshot\u3002\u5728\u7ebf\u6027 Graph \u4e2d&#xff0c;\u4e00\u4e2a super-step \u5f80\u5f80\u5bf9\u5e94\u4e00\u6b21\u8282\u70b9\u63a8\u8fdb&#xff1b;\u5728\u5e76\u884c Graph \u4e2d&#xff0c;\u5219\u53ef\u80fd\u6709\u591a\u4e2a\u8282\u70b9\u5904\u4e8e\u540c\u4e00\u4e2a super-step\u3002<\/p>\n<p>\u73b0\u5728\u9488\u5bf9\u672c\u6b21\u6559\u5b66&#xff0c;\u6211\u4eec\u5b8c\u6574\u7684\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p>&#034;&#034;&#034;Demo 02: Checkpoint Basics \u2014 MemorySaver\u3001Thread ID\u3001\u72b6\u6001\u6062\u590d\u3002<\/p>\n<p>\u6f14\u793a LangGraph \u5185\u7f6e\u7684 Checkpoint \u673a\u5236&#xff1a;<br \/>\n1. MemorySaver&#xff1a;\u7eaf\u5185\u5b58\u7684 Checkpoint \u540e\u7aef<br \/>\n2. Thread ID&#xff1a;\u7ebf\u7a0b\u9694\u79bb&#xff0c;\u4e0d\u540c\u5bf9\u8bdd\u4e92\u4e0d\u5e72\u6270<br \/>\n3. \u72b6\u6001\u6062\u590d&#xff1a;\u4e2d\u65ad\u540e\u4ece\u6700\u8fd1\u4e00\u6b21 Checkpoint \u6062\u590d\u6267\u884c<\/p>\n<p>\u8fd0\u884c\u65b9\u5f0f&#xff1a;<br \/>\n    python stages\/stage3_memory\/02_checkpoint_basics\/main.py<br \/>\n&#034;&#034;&#034;<\/p>\n<p>from __future__ import annotations<\/p>\n<p>import sys<br \/>\nfrom pathlib import Path<br \/>\nfrom typing import Annotated, TypedDict<\/p>\n<p>from langchain_core.messages import BaseMessage, HumanMessage<br \/>\nfrom langgraph.checkpoint.memory import MemorySaver<br \/>\nfrom langgraph.graph import END, START, StateGraph<br \/>\nfrom langgraph.graph.message import add_messages<\/p>\n<p>sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent.parent))<\/p>\n<p>from shared import get_llm, get_logger, log_step, log_success<\/p>\n<p>logger &#061; get_logger(&#034;demo.02_checkpoint_basics&#034;)<\/p>\n<p>class ChatState(TypedDict):<br \/>\n    messages: Annotated[list[BaseMessage], add_messages]<br \/>\n    turn_count: int<\/p>\n<p>def build_checkpoint_graph():<br \/>\n    &#034;&#034;&#034;\u6784\u5efa\u5e26 Checkpoint \u652f\u6301\u7684\u5bf9\u8bdd\u56fe\u3002&#034;&#034;&#034;<br \/>\n    llm &#061; get_llm(fallback_to_mock&#061;False)<\/p>\n<p>    def chat_node(state: ChatState) -&gt; dict:<br \/>\n        log_step(logger, &#034;chat_node&#034;, f&#034;\u7b2c {state.get(&#039;turn_count&#039;, 0) &#043; 1} \u8f6e\u5bf9\u8bdd&#034;)<br \/>\n        response &#061; llm.invoke(state[&#034;messages&#034;])<br \/>\n        return {<br \/>\n            &#034;messages&#034;: [response],<br \/>\n            &#034;turn_count&#034;: state.get(&#034;turn_count&#034;, 0) &#043; 1,<br \/>\n        }<\/p>\n<p>    graph &#061; StateGraph(ChatState)<br \/>\n    graph.add_node(&#034;chat&#034;, chat_node)<br \/>\n    graph.add_edge(START, &#034;chat&#034;)<br \/>\n    graph.add_edge(&#034;chat&#034;, END)<br \/>\n    return graph<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n# \u6f14\u793a 1&#xff1a;\u57fa\u672c Checkpoint \u4f7f\u7528<br \/>\n# &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\ndef demo_basic_checkpoint():<br \/>\n    &#034;&#034;&#034;\u6f14\u793a MemorySaver \u7684\u57fa\u672c\u7528\u6cd5\u3002&#034;&#034;&#034;<br \/>\n    print(&#034;\\\\n&#8212; \u6f14\u793a 1: MemorySaver \u57fa\u672c\u7528\u6cd5 &#8212;\\\\n&#034;)<\/p>\n<p>    checkpointer &#061; MemorySaver()<br \/>\n    graph &#061; build_checkpoint_graph()<br \/>\n    app &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>    config &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;demo-thread-1&#034;}}<\/p>\n<p>    conversations &#061; [<br \/>\n        &#034;\u4f60\u597d&#xff0c;\u6211\u53eb\u674e\u660e&#034;,<br \/>\n        &#034;\u6211\u662f\u4e00\u540d Python \u5f00\u53d1\u8005&#034;,<br \/>\n        &#034;\u4f60\u8fd8\u8bb0\u5f97\u6211\u53eb\u4ec0\u4e48\u5417&#xff1f;&#034;,<br \/>\n    ]<\/p>\n<p>    results &#061; []<br \/>\n    for user_msg in conversations:<br \/>\n        print(f&#034;  \u7528\u6237: {user_msg}&#034;)<br \/>\n        result &#061; app.invoke(<br \/>\n            {&#034;messages&#034;: [HumanMessage(content&#061;user_msg)], &#034;turn_count&#034;: 0},<br \/>\n            config&#061;config,<br \/>\n        )<br \/>\n        ai_msg &#061; result[&#034;messages&#034;][-1]<br \/>\n        print(f&#034;  \u52a9\u624b: {ai_msg.content}&#034;)<br \/>\n        print()<br \/>\n        results.append(result)<\/p>\n<p>    snapshot &#061; app.get_state(config)<br \/>\n    print(&#034;  Checkpoint \u72b6\u6001:&#034;)<br \/>\n    print(f&#034;    \u6d88\u606f\u6570\u91cf: {len(snapshot.values.get(&#039;messages&#039;, []))}&#034;)<br \/>\n    print(f&#034;    \u5bf9\u8bdd\u8f6e\u6b21: {snapshot.values.get(&#039;turn_count&#039;, &#039;N\/A&#039;)}&#034;)<br \/>\n    print()<\/p>\n<p>    return {&#034;results&#034;: results, &#034;checkpointer&#034;: checkpointer, &#034;config&#034;: config}<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n# \u6f14\u793a 2&#xff1a;Thread ID \u9694\u79bb<br \/>\n# &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\ndef demo_thread_isolation():<br \/>\n    &#034;&#034;&#034;\u6f14\u793a\u4e0d\u540c thread_id \u4e4b\u95f4\u7684\u72b6\u6001\u9694\u79bb\u3002&#034;&#034;&#034;<br \/>\n    print(&#034;\\\\n&#8212; \u6f14\u793a 2: Thread ID \u9694\u79bb &#8212;\\\\n&#034;)<\/p>\n<p>    checkpointer &#061; MemorySaver()<br \/>\n    graph &#061; build_checkpoint_graph()<br \/>\n    app &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>    config_alice &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;user-alice&#034;}}<br \/>\n    config_bob &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;user-bob&#034;}}<\/p>\n<p>    print(&#034;  [Alice \u7684\u5bf9\u8bdd]&#034;)<br \/>\n    app.invoke(<br \/>\n        {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u6211\u53eb Alice&#xff0c;\u6211\u559c\u6b22\u732b&#034;)], &#034;turn_count&#034;: 0},<br \/>\n        config&#061;config_alice,<br \/>\n    )<br \/>\n    print(&#034;    Alice: \u6211\u53eb Alice&#xff0c;\u6211\u559c\u6b22\u732b&#034;)<\/p>\n<p>    print(&#034;  [Bob \u7684\u5bf9\u8bdd]&#034;)<br \/>\n    app.invoke(<br \/>\n        {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u6211\u53eb Bob&#xff0c;\u6211\u559c\u6b22\u72d7&#034;)], &#034;turn_count&#034;: 0},<br \/>\n        config&#061;config_bob,<br \/>\n    )<br \/>\n    print(&#034;    Bob: \u6211\u53eb Bob&#xff0c;\u6211\u559c\u6b22\u72d7&#034;)<\/p>\n<p>    print(&#034;\\\\n  [\u9a8c\u8bc1\u9694\u79bb]&#034;)<br \/>\n    alice_state &#061; app.get_state(config_alice)<br \/>\n    bob_state &#061; app.get_state(config_bob)<\/p>\n<p>    alice_msgs &#061; alice_state.values.get(&#034;messages&#034;, [])<br \/>\n    bob_msgs &#061; bob_state.values.get(&#034;messages&#034;, [])<\/p>\n<p>    print(f&#034;    Alice \u6d88\u606f\u6570: {len(alice_msgs)}&#034;)<br \/>\n    print(f&#034;    Bob \u6d88\u606f\u6570: {len(bob_msgs)}&#034;)<\/p>\n<p>    alice_has_alice &#061; any(&#034;Alice&#034; in str(m.content) or &#034;alice&#034; in str(m.content) for m in alice_msgs)<br \/>\n    bob_has_bob &#061; any(&#034;Bob&#034; in str(m.content) or &#034;bob&#034; in str(m.content) for m in bob_msgs)<br \/>\n    print(f&#034;    Alice \u5bf9\u8bdd\u5305\u542b &#039;Alice&#039;: {alice_has_alice}&#034;)<br \/>\n    print(f&#034;    Bob \u5bf9\u8bdd\u5305\u542b &#039;Bob&#039;: {bob_has_bob}&#034;)<br \/>\n    print()<\/p>\n<p>    return {<br \/>\n        &#034;alice_msg_count&#034;: len(alice_msgs),<br \/>\n        &#034;bob_msg_count&#034;: len(bob_msgs),<br \/>\n        &#034;isolation_verified&#034;: True,<br \/>\n    }<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n# \u6f14\u793a 3&#xff1a;\u72b6\u6001\u6062\u590d<br \/>\n# &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\ndef demo_state_recovery():<br \/>\n    &#034;&#034;&#034;\u6f14\u793a\u4ece Checkpoint \u6062\u590d\u72b6\u6001\u3002&#034;&#034;&#034;<br \/>\n    print(&#034;\\\\n&#8212; \u6f14\u793a 3: \u72b6\u6001\u6062\u590d &#8212;\\\\n&#034;)<\/p>\n<p>    checkpointer &#061; MemorySaver()<br \/>\n    graph &#061; build_checkpoint_graph()<\/p>\n<p>    config &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;recovery-thread&#034;}}<\/p>\n<p>    log_step(logger, &#034;\u9636\u6bb5 1&#034;, &#034;\u521b\u5efa\u5bf9\u8bdd\u5e76\u79ef\u7d2f\u72b6\u6001&#034;)<br \/>\n    app1 &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>    app1.invoke(<br \/>\n        {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u8bb0\u4f4f&#xff1a;\u6211\u7684\u5bc6\u7801\u63d0\u793a\u662f&#039;\u84dd\u8272\u7684\u5929\u7a7a&#039;&#034;)], &#034;turn_count&#034;: 0},<br \/>\n        config&#061;config,<br \/>\n    )<br \/>\n    app1.invoke(<br \/>\n        {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u6211\u6700\u559c\u6b22\u7684\u7f16\u7a0b\u8bed\u8a00\u662f Rust&#034;)], &#034;turn_count&#034;: 0},<br \/>\n        config&#061;config,<br \/>\n    )<br \/>\n    print(&#034;  \u9636\u6bb5 1: \u5df2\u5199\u5165 2 \u8f6e\u5bf9\u8bdd&#034;)<\/p>\n<p>    state_before &#061; app1.get_state(config)<br \/>\n    msg_count_before &#061; len(state_before.values.get(&#034;messages&#034;, []))<br \/>\n    print(f&#034;  Checkpoint \u4e2d\u6d88\u606f\u6570: {msg_count_before}&#034;)<\/p>\n<p>    log_step(logger, &#034;\u9636\u6bb5 2&#034;, &#034;\u6a21\u62df\u8fdb\u7a0b\u91cd\u542f \u2014 \u7528\u540c\u4e00\u4e2a checkpointer \u521b\u5efa\u65b0\u7684 app&#034;)<br \/>\n    app2 &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>    state_after &#061; app2.get_state(config)<br \/>\n    msg_count_after &#061; len(state_after.values.get(&#034;messages&#034;, []))<br \/>\n    print(f&#034;  \u6062\u590d\u540e\u6d88\u606f\u6570: {msg_count_after}&#034;)<\/p>\n<p>    result &#061; app2.invoke(<br \/>\n        {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u6211\u6700\u559c\u6b22\u4ec0\u4e48\u7f16\u7a0b\u8bed\u8a00&#xff1f;&#034;)], &#034;turn_count&#034;: 0},<br \/>\n        config&#061;config,<br \/>\n    )<br \/>\n    final_msg &#061; result[&#034;messages&#034;][-1]<br \/>\n    print(&#034;  \u7528\u6237: \u6211\u6700\u559c\u6b22\u4ec0\u4e48\u7f16\u7a0b\u8bed\u8a00&#xff1f;&#034;)<br \/>\n    print(f&#034;  \u52a9\u624b: {final_msg.content}&#034;)<\/p>\n<p>    log_success(logger, f&#034;\u72b6\u6001\u6062\u590d\u6210\u529f&#xff01;\u6062\u590d\u524d {msg_count_before} \u6761 \u2192 \u6062\u590d\u540e {msg_count_after} \u6761&#034;)<br \/>\n    print()<\/p>\n<p>    return {<br \/>\n        &#034;msg_count_before&#034;: msg_count_before,<br \/>\n        &#034;msg_count_after&#034;: msg_count_after,<br \/>\n        &#034;recovery_success&#034;: msg_count_after &#061;&#061; msg_count_before,<br \/>\n    }<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\n# \u6f14\u793a 4&#xff1a;\u67e5\u770b Checkpoint \u5386\u53f2<br \/>\n# &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\ndef demo_checkpoint_history():<br \/>\n    &#034;&#034;&#034;\u6f14\u793a\u67e5\u770b Checkpoint \u7684\u5386\u53f2\u7248\u672c\u3002&#034;&#034;&#034;<br \/>\n    print(&#034;\\\\n&#8212; \u6f14\u793a 4: Checkpoint \u5386\u53f2\u7248\u672c &#8212;\\\\n&#034;)<\/p>\n<p>    checkpointer &#061; MemorySaver()<br \/>\n    graph &#061; build_checkpoint_graph()<br \/>\n    app &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>    config &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;history-thread&#034;}}<\/p>\n<p>    steps &#061; [&#034;\u7b2c\u4e00\u6b65&#034;, &#034;\u7b2c\u4e8c\u6b65&#034;, &#034;\u7b2c\u4e09\u6b65&#034;]<br \/>\n    for step in steps:<br \/>\n        app.invoke(<br \/>\n            {&#034;messages&#034;: [HumanMessage(content&#061;f&#034;\u8fd9\u662f{step}&#034;)], &#034;turn_count&#034;: 0},<br \/>\n            config&#061;config,<br \/>\n        )<\/p>\n<p>    print(&#034;  Checkpoint \u5386\u53f2:&#034;)<br \/>\n    history_count &#061; 0<br \/>\n    for state in app.get_state_history(config):<br \/>\n        history_count &#043;&#061; 1<br \/>\n        msg_count &#061; len(state.values.get(&#034;messages&#034;, []))<br \/>\n        ts &#061; state.config.get(&#034;configurable&#034;, {}).get(&#034;checkpoint_id&#034;, &#034;N\/A&#034;)<br \/>\n        print(f&#034;    \u7248\u672c {history_count}: {msg_count} \u6761\u6d88\u606f, checkpoint_id&#061;{ts[:20]}&#8230;&#034;)<br \/>\n        if history_count &gt;&#061; 6:<br \/>\n            print(&#034;    &#8230; (\u66f4\u591a\u5386\u53f2\u7701\u7565)&#034;)<br \/>\n            break<\/p>\n<p>    print(f&#034;\\\\n  \u603b\u5171 {history_count}&#043; \u4e2a Checkpoint \u7248\u672c&#034;)<br \/>\n    print()<\/p>\n<p>    return {&#034;history_count&#034;: history_count}<\/p>\n<p>def run_demo() -&gt; dict:<br \/>\n    &#034;&#034;&#034;\u8fd0\u884c Checkpoint Basics \u5168\u90e8\u6f14\u793a\u3002&#034;&#034;&#034;<br \/>\n    print(&#034;&#061;&#034; * 60)<br \/>\n    print(&#034;  Demo 02: Checkpoint Basics \u2014 \u72b6\u6001\u6301\u4e45\u5316\u57fa\u7840&#034;)<br \/>\n    print(&#034;&#061;&#034; * 60)<\/p>\n<p>    basic &#061; demo_basic_checkpoint()<br \/>\n    isolation &#061; demo_thread_isolation()<br \/>\n    recovery &#061; demo_state_recovery()<br \/>\n    history &#061; demo_checkpoint_history()<\/p>\n<p>    print()<br \/>\n    print(&#034;&#061;&#034; * 60)<br \/>\n    print(&#034;  \u5173\u952e\u6982\u5ff5\u56de\u987e&#034;)<br \/>\n    print(&#034;&#061;&#034; * 60)<br \/>\n    print(&#034;  1. MemorySaver  : LangGraph \u5185\u7f6e\u7684\u7eaf\u5185\u5b58 Checkpoint \u540e\u7aef&#034;)<br \/>\n    print(&#034;  2. thread_id    : \u901a\u8fc7 config \u4f20\u5165&#xff0c;\u5b9e\u73b0\u5bf9\u8bdd\u7ebf\u7a0b\u9694\u79bb&#034;)<br \/>\n    print(&#034;  3. \u72b6\u6001\u6062\u590d     : \u540c\u4e00 thread_id \u81ea\u52a8\u4ece\u6700\u8fd1 Checkpoint \u6062\u590d&#034;)<br \/>\n    print(&#034;  4. \u5386\u53f2\u7248\u672c     : \u6bcf\u6b21 invoke \u90fd\u4f1a\u521b\u5efa\u65b0\u7684 Checkpoint \u7248\u672c&#034;)<br \/>\n    print(&#034;  5. get_state()  : \u67e5\u770b\u5f53\u524d\u7ebf\u7a0b\u7684\u6700\u65b0\u72b6\u6001&#034;)<br \/>\n    print(&#034;  6. get_state_history(): \u67e5\u770b\u6240\u6709\u5386\u53f2 Checkpoint&#034;)<br \/>\n    print()<\/p>\n<p>    return {<br \/>\n        &#034;basic&#034;: basic,<br \/>\n        &#034;isolation&#034;: isolation,<br \/>\n        &#034;recovery&#034;: recovery,<br \/>\n        &#034;history&#034;: history,<br \/>\n    }<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    run_demo()<\/p>\n<h2 id=\"%E4%B8%89%E3%80%81Checkpoint%E3%80%81Thread%20%E4%B8%8E%E7%89%88%E6%9C%AC%E9%93%BE\">\u4e09\u3001Checkpoint\u3001Thread \u4e0e\u7248\u672c\u94fe<\/h2>\n<p>\u6574\u4e2a Checkpoint \u7cfb\u7edf\u53ef\u4ee5\u62c6\u6210\u4e09\u4e2a\u6838\u5fc3\u6982\u5ff5\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89Checkpointer%EF%BC%9A%E7%8A%B6%E6%80%81%E4%BF%9D%E5%AD%98%E5%90%8E%E7%AB%AF\">&#xff08;\u4e00&#xff09;Checkpointer&#xff1a;\u72b6\u6001\u4fdd\u5b58\u540e\u7aef<\/h3>\n<p>Checkpointer \u51b3\u5b9a\u72b6\u6001\u4fdd\u5b58\u5728\u54ea\u91cc\u3002\u672c\u6587\u4ee3\u7801\u4f7f\u7528&#xff09;&#xff1a;<\/p>\n<p>from langgraph.checkpoint.memory import MemorySaver<\/p>\n<p>\u5e76\u521b\u5efa\u4e00\u4e2a\u7eaf\u5185\u5b58\u540e\u7aef&#xff1a;<\/p>\n<p>checkpointer &#061; MemorySaver()<\/p>\n<p>MemorySaver \u4f7f\u7528\u5f53\u524d Python \u8fdb\u7a0b\u7684\u5185\u5b58\u4fdd\u5b58 Checkpoint&#xff0c;\u9002\u5408&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u672c\u5730\u5b66\u4e60&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5355\u5143\u6d4b\u8bd5&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5feb\u901f\u9a8c\u8bc1&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5f00\u53d1\u9636\u6bb5\u8c03\u8bd5\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f46\u5b83\u4e0d\u9002\u5408\u771f\u6b63\u7684\u751f\u4ea7\u6301\u4e45\u5316&#xff0c;\u56e0\u4e3a Python \u8fdb\u7a0b\u9000\u51fa\u540e&#xff0c;\u5185\u5b58\u4e2d\u7684\u6570\u636e\u4e5f\u4f1a\u6d88\u5931\u3002\u5b98\u65b9\u6587\u6863\u540c\u6837\u660e\u786e\u6307\u51fa&#xff0c;MemorySaver \u548c InMemorySaver \u7684\u6570\u636e\u4e0d\u4f1a\u5728\u8fdb\u7a0b\u91cd\u542f\u540e\u4fdd\u7559\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89Thread%20ID%EF%BC%9A%E4%B8%80%E6%9D%A1%E7%8A%B6%E6%80%81%E9%93%BE%E7%9A%84%E4%B8%9A%E5%8A%A1%E6%A0%87%E8%AF%86\">&#xff08;\u4e8c&#xff09;Thread ID&#xff1a;\u4e00\u6761\u72b6\u6001\u94fe\u7684\u4e1a\u52a1\u6807\u8bc6<\/h3>\n<p>\u6bcf\u6b21\u8c03\u7528\u5e26 Checkpointer \u7684 Graph \u65f6&#xff0c;\u90fd\u9700\u8981\u4f20\u5165&#xff1a;<\/p>\n<p>config &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;demo-thread-1&#034;}}<\/p>\n<p>thread_id \u53ef\u4ee5\u7406\u89e3\u6210\u4e00\u628a\u94a5\u5319\u3002<\/p>\n<ul>\n<li>\n<p>\u76f8\u540c\u7684 thread_id&#xff1a;\u7ee7\u7eed\u8bfb\u53d6\u539f\u6709\u72b6\u6001&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u540c\u7684 thread_id&#xff1a;\u521b\u5efa\u76f8\u4e92\u9694\u79bb\u7684\u65b0\u7ebf\u7a0b&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6ca1\u6709 thread_id&#xff1a;Checkpointer \u4e0d\u77e5\u9053\u5e94\u8be5\u8bfb\u53d6\u6216\u5199\u5165\u54ea\u6761\u72b6\u6001\u94fe\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5b98\u65b9\u6587\u6863\u5c06 thread_id \u63cf\u8ff0\u4e3a Checkpointer \u4fdd\u5b58\u548c\u52a0\u8f7d\u72b6\u6001\u65f6\u4f7f\u7528\u7684\u4e3b\u8981\u6807\u8bc6\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%89%EF%BC%89Checkpoint%20%E7%89%88%E6%9C%AC%E9%93%BE%EF%BC%9A%E7%8A%B6%E6%80%81%E4%B8%8D%E5%8F%AA%E6%9C%89%E2%80%9C%E7%8E%B0%E5%9C%A8%E2%80%9D\">&#xff08;\u4e09&#xff09;Checkpoint \u7248\u672c\u94fe&#xff1a;\u72b6\u6001\u4e0d\u53ea\u6709\u201c\u73b0\u5728\u201d<\/h3>\n<p>\u540c\u4e00\u4e2a\u7ebf\u7a0b\u4e0d\u662f\u53ea\u4fdd\u5b58\u4e00\u4e2a\u6700\u7ec8\u72b6\u6001\u3002\u968f\u7740 Graph \u4e0d\u65ad\u6267\u884c&#xff0c;Checkpointer \u4f1a\u6301\u7eed\u4ea7\u751f\u65b0\u7684\u72b6\u6001\u7248\u672c&#xff1a;<\/p>\n<p>checkpoint_1<br \/>\n    \u2193<br \/>\ncheckpoint_2<br \/>\n    \u2193<br \/>\ncheckpoint_3<br \/>\n    \u2193<br \/>\ncheckpoint_4<\/p>\n<p>\u8fd9\u610f\u5473\u7740\u5e94\u7528\u4e0d\u4ec5\u80fd\u591f\u8bfb\u53d6\u201c\u6700\u65b0\u72b6\u6001\u201d&#xff0c;\u8fd8\u53ef\u4ee5\u67e5\u770b\u5386\u53f2\u72b6\u6001&#xff0c;\u5e76\u4ece\u67d0\u4e2a\u5386\u53f2 Checkpoint \u91cd\u65b0\u6267\u884c\u540e\u7eed\u8282\u70b9\u3002<\/p>\n<p>\u8fd9\u4e5f\u662f LangGraph \u80fd\u591f\u5b9e\u73b0\u4ee5\u4e0b\u80fd\u529b\u7684\u57fa\u7840&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5bf9\u8bdd\u72b6\u6001\u6062\u590d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Human-in-the-loop&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6545\u969c\u7eed\u8dd1&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5386\u53f2\u8c03\u8bd5&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Replay&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Fork&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Time Travel\u3002<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"%EF%BC%88%E5%9B%9B%EF%BC%89%E4%B8%80%E6%AC%A1%20invoke%20%E5%88%B0%E5%BA%95%E5%8F%91%E7%94%9F%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F\">&#xff08;\u56db&#xff09;\u4e00\u6b21 invoke \u5230\u5e95\u53d1\u751f\u4e86\u4ec0\u4e48&#xff1f;<\/h3>\n<p>\u53ef\u4ee5\u628a\u4e00\u6b21\u8c03\u7528\u7406\u89e3\u6210\u4ee5\u4e0b\u8fc7\u7a0b&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"423\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005008-6a7288c04764f.png\" width=\"800\" \/><\/p>\n<p>\u8fd9\u91cc\u6700\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u662f <span style=\"color:#fe2c24\">Reducer<\/span>\u3002<\/p>\n<p>\u6062\u590d\u72b6\u6001\u5e76\u4e0d\u610f\u5473\u7740\u7b80\u5355\u5730\u7528\u65b0\u8f93\u5165\u8986\u76d6\u65e7\u72b6\u6001\u3002\u6bcf\u4e00\u4e2a State \u5b57\u6bb5\u90fd\u6709\u81ea\u5df1\u7684\u66f4\u65b0\u89c4\u5219&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u58f0\u660e\u4e86 Reducer \u7684\u5b57\u6bb5&#xff0c;\u6309\u7167 Reducer \u5408\u5e76&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6ca1\u6709\u58f0\u660e Reducer \u7684\u5b57\u6bb5&#xff0c;\u901a\u5e38\u7531\u65b0\u503c\u76f4\u63a5\u8986\u76d6\u65e7\u503c\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5728\u672c\u6587\u4ee3\u7801\u4e2d&#xff1a;<\/p>\n<p>class ChatState(TypedDict):<br \/>\n    messages: Annotated[list[BaseMessage], add_messages]<br \/>\n    turn_count: int<\/p>\n<p>messages \u4f7f\u7528\u4e86 add_messages&#xff0c;\u56e0\u6b64\u65b0\u7684\u6d88\u606f\u4f1a\u8ffd\u52a0\u5230\u5df2\u6709\u6d88\u606f\u5217\u8868\u4e2d\u3002<\/p>\n<p>turn_count \u6ca1\u6709\u81ea\u5b9a\u4e49 Reducer&#xff0c;\u6240\u4ee5\u5b83\u91c7\u7528\u9ed8\u8ba4\u8986\u76d6\u884c\u4e3a\u3002<\/p>\n<p>\u8fd9\u4e2a\u5dee\u5f02&#xff0c;\u6b63\u662f\u540e\u9762\u51fa\u73b0\u201c\u6d88\u606f\u6570\u91cf\u662f 6&#xff0c;\u4f46 turn_count \u59cb\u7ec8\u662f 1\u201d\u7684\u539f\u56e0\u3002<\/p>\n<h2 id=\"%E5%9B%9B%E3%80%81%E4%BB%A3%E7%A0%81%E6%BC%94%E7%A4%BA%E8%AF%A6%E7%BB%86%E8%AF%B4%E6%98%8E\">\u56db\u3001\u4ee3\u7801\u6f14\u793a\u8be6\u7ec6\u8bf4\u660e<\/h2>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84%E5%88%86%E6%9E%90\">&#xff08;\u4e00&#xff09;\u4ee3\u7801\u7ed3\u6784\u5206\u6790<\/h3>\n<p>\u672c\u6587 Demo \u7684 Graph \u975e\u5e38\u7b80\u5355&#xff1a;<\/p>\n<p>START \u2192 chat \u2192 END<\/p>\n<p>Graph \u7684\u6784\u5efa\u4ee3\u7801\u5982\u4e0b&#xff0c;\u4fdd\u6301\u539f\u6837&#xff1a;<\/p>\n<p>def build_checkpoint_graph():<br \/>\n    &#034;&#034;&#034;\u6784\u5efa\u5e26 Checkpoint \u652f\u6301\u7684\u5bf9\u8bdd\u56fe\u3002&#034;&#034;&#034;<br \/>\n    llm &#061; get_llm(fallback_to_mock&#061;False)<\/p>\n<p>    def chat_node(state: ChatState) -&gt; dict:<br \/>\n        log_step(logger, &#034;chat_node&#034;, f&#034;\u7b2c {state.get(&#039;turn_count&#039;, 0) &#043; 1} \u8f6e\u5bf9\u8bdd&#034;)<br \/>\n        response &#061; llm.invoke(state[&#034;messages&#034;])<br \/>\n        return {<br \/>\n            &#034;messages&#034;: [response],<br \/>\n            &#034;turn_count&#034;: state.get(&#034;turn_count&#034;, 0) &#043; 1,<br \/>\n        }<\/p>\n<p>    graph &#061; StateGraph(ChatState)<br \/>\n    graph.add_node(&#034;chat&#034;, chat_node)<br \/>\n    graph.add_edge(START, &#034;chat&#034;)<br \/>\n    graph.add_edge(&#034;chat&#034;, END)<br \/>\n    return graph<\/p>\n<p>chat_node \u505a\u4e86\u4e24\u4ef6\u4e8b&#xff1a;<\/p>\n<li>\n<p>\u5c06\u5f53\u524d messages \u4f20\u7ed9\u6a21\u578b&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u4e00\u6761\u65b0\u7684 AI \u6d88\u606f\u548c\u66f4\u65b0\u540e\u7684 turn_count\u3002<\/p>\n<\/li>\n<p>\u9700\u8981\u6ce8\u610f&#xff0c;build_checkpoint_graph() \u8fd4\u56de\u7684\u53ea\u662f Graph Builder\u3002<\/p>\n<p>\u771f\u6b63\u8ba9 Graph \u83b7\u5f97\u72b6\u6001\u4fdd\u5b58\u80fd\u529b\u7684&#xff0c;\u662f\u7f16\u8bd1\u65f6\u4f20\u5165\u7684 Checkpointer&#xff1a;<\/p>\n<p>checkpointer &#061; MemorySaver()<br \/>\ngraph &#061; build_checkpoint_graph()<br \/>\napp &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>\u540c\u4e00\u4efd Graph \u7ed3\u6784&#xff0c;\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6302\u8f7d\u4e0d\u540c\u540e\u7aef&#xff1a;<\/p>\n<p>Graph Builder<br \/>\n    \u251c\u2500\u2500 compile(checkpointer&#061;MemorySaver)<br \/>\n    \u251c\u2500\u2500 compile(checkpointer&#061;SQLite Saver)<br \/>\n    \u251c\u2500\u2500 compile(checkpointer&#061;PostgreSQL Saver)<br \/>\n    \u2514\u2500\u2500 compile(checkpointer&#061;Redis Saver)<\/p>\n<p>Graph \u8d1f\u8d23\u5b9a\u4e49\u6267\u884c\u903b\u8f91&#xff0c;Checkpointer \u8d1f\u8d23\u4fdd\u5b58\u6267\u884c\u72b6\u6001\u3002\u4e24\u8005\u662f\u89e3\u8026\u7684\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E8%AF%A6%E7%BB%86%E6%BC%94%E7%A4%BA%E8%AF%B4%E6%98%8E%E5%88%86%E6%9E%90\">&#xff08;\u4e8c&#xff09;\u8be6\u7ec6\u6f14\u793a\u8bf4\u660e\u5206\u6790<\/h3>\n<h4 id=\"1.%20%E6%BC%94%E7%A4%BA%201%EF%BC%9AMemorySaver%20%E5%9F%BA%E6%9C%AC%E7%94%A8%E6%B3%95\">1. \u6f14\u793a 1&#xff1a;MemorySaver \u57fa\u672c\u7528\u6cd5<\/h4>\n<p>\u7b2c\u4e00\u4e2a\u6f14\u793a\u8fde\u7eed\u53d1\u8d77\u4e09\u8f6e\u5bf9\u8bdd&#xff1a;<\/p>\n<p>conversations &#061; [<br \/>\n    &#034;\u4f60\u597d&#xff0c;\u6211\u53eb\u674e\u660e&#034;,<br \/>\n    &#034;\u6211\u662f\u4e00\u540d Python \u5f00\u53d1\u8005&#034;,<br \/>\n    &#034;\u4f60\u8fd8\u8bb0\u5f97\u6211\u53eb\u4ec0\u4e48\u5417&#xff1f;&#034;,<br \/>\n]<\/p>\n<p>\u6240\u6709\u8bf7\u6c42\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u914d\u7f6e&#xff1a;<\/p>\n<p>config &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;demo-thread-1&#034;}}<\/p>\n<p>\u8c03\u7528\u4ee3\u7801\u4fdd\u6301\u539f\u6837&#xff1a;<\/p>\n<p>result &#061; app.invoke(<br \/>\n    {&#034;messages&#034;: [HumanMessage(content&#061;user_msg)], &#034;turn_count&#034;: 0},<br \/>\n    config&#061;config,<br \/>\n)<\/p>\n<p>\u4e09\u6b21\u8c03\u7528\u7684\u72b6\u6001\u53d8\u5316\u53ef\u4ee5\u8868\u793a\u4e3a&#xff1a;<\/p>\n<table>\n<tr>\u8c03\u7528\u65b0\u589e Human \u6d88\u606f\u65b0\u589e AI \u6d88\u606f\u6700\u7ec8\u6d88\u606f\u6570<\/tr>\n<tbody>\n<tr>\n<td>\u7b2c 1 \u6b21<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>\u7b2c 2 \u6b21<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>\u7b2c 3 \u6b21<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b2c\u4e09\u6b21\u8c03\u7528\u524d&#xff0c;Graph \u4f1a\u5148\u6062\u590d\u524d\u4e24\u6b21\u8c03\u7528\u7559\u4e0b\u7684\u6d88\u606f&#xff1a;<\/p>\n<p>Human: \u4f60\u597d&#xff0c;\u6211\u53eb\u674e\u660e<br \/>\nAI: \u4f60\u597d&#xff0c;\u674e\u660e\u2026\u2026<br \/>\nHuman: \u6211\u662f\u4e00\u540d Python \u5f00\u53d1\u8005<br \/>\nAI: \u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u2026\u2026<br \/>\nHuman: \u4f60\u8fd8\u8bb0\u5f97\u6211\u53eb\u4ec0\u4e48\u5417&#xff1f;<\/p>\n<p>\u6a21\u578b\u6536\u5230\u7684\u5e76\u4e0d\u53ea\u662f\u6700\u540e\u4e00\u4e2a\u95ee\u9898&#xff0c;\u800c\u662f\u6062\u590d\u5e76\u5408\u5e76\u540e\u7684\u5b8c\u6574\u6d88\u606f\u5e8f\u5217&#xff0c;\u56e0\u6b64\u5b83\u80fd\u591f\u56de\u7b54\u201c\u674e\u660e\u201d\u3002<\/p>\n<p>\u6700\u540e\u901a\u8fc7&#xff1a;<\/p>\n<p>snapshot &#061; app.get_state(config)<\/p>\n<p>\u8bfb\u53d6\u6700\u65b0\u72b6\u6001&#xff1a;<\/p>\n<p>Checkpoint \u72b6\u6001:<br \/>\n  \u6d88\u606f\u6570\u91cf: 6<br \/>\n  \u5bf9\u8bdd\u8f6e\u6b21: 1<\/p>\n<h5 id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%20turn_count%20%E6%98%AF%201%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%203%EF%BC%9F\">\u4e3a\u4ec0\u4e48 turn_count \u662f 1&#xff0c;\u800c\u4e0d\u662f 3&#xff1f;<\/h5>\n<p>\u5173\u952e\u5728\u4e8e\u6bcf\u6b21\u8c03\u7528\u90fd\u663e\u5f0f\u4f20\u5165\u4e86&#xff1a;<\/p>\n<p>&#034;turn_count&#034;: 0<\/p>\n<p>\u800c turn_count \u6ca1\u6709 Reducer\u3002<\/p>\n<p>\u56e0\u6b64\u6bcf\u4e00\u6b21 invoke \u6062\u590d\u65e7\u72b6\u6001\u4e4b\u540e&#xff0c;\u672c\u6b21\u8f93\u5165\u4e2d\u7684 0 \u53c8\u4f1a\u8986\u76d6\u65e7\u503c&#xff0c;\u968f\u540e chat_node \u6267\u884c&#xff1a;<\/p>\n<p>state.get(&#034;turn_count&#034;, 0) &#043; 1<\/p>\n<p>\u6700\u7ec8\u91cd\u65b0\u5f97\u5230 1\u3002<\/p>\n<p>\u6267\u884c\u8fc7\u7a0b\u5b9e\u9645\u4e0a\u662f&#xff1a;<\/p>\n<p>\u4e0a\u6b21 Checkpoint&#xff1a;turn_count &#061; 1<br \/>\n        \u2193<br \/>\n\u672c\u6b21\u8f93\u5165\u8986\u76d6&#xff1a;turn_count &#061; 0<br \/>\n        \u2193<br \/>\nchat_node \u52a0\u4e00&#xff1a;turn_count &#061; 1<\/p>\n<p>\u8fd9\u4e2a\u73b0\u8c61\u975e\u5e38\u6709\u6559\u5b66\u4ef7\u503c&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\"><span style=\"background-color:#fefcd8\">Checkpoint \u8d1f\u8d23\u6062\u590d\u72b6\u6001&#xff0c;\u4f46\u72b6\u6001\u5982\u4f55\u5408\u5e76&#xff0c;\u6700\u7ec8\u7531\u6bcf\u4e2a\u5b57\u6bb5\u7684 Reducer \u51b3\u5b9a\u3002<\/span><\/span><\/p>\n<h4 id=\"2.%20%E6%BC%94%E7%A4%BA%202%EF%BC%9AThread%20ID%20%E9%9A%94%E7%A6%BB\">2. \u6f14\u793a 2&#xff1a;Thread ID \u9694\u79bb<\/h4>\n<p>\u7b2c\u4e8c\u4e2a\u6f14\u793a\u521b\u5efa\u4e86\u4e24\u4e2a\u72ec\u7acb\u7ebf\u7a0b&#xff1a;<\/p>\n<p>config_alice &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;user-alice&#034;}}<br \/>\nconfig_bob &#061; {&#034;configurable&#034;: {&#034;thread_id&#034;: &#034;user-bob&#034;}}<\/p>\n<p>Alice \u7ebf\u7a0b\u5199\u5165&#xff1a;<\/p>\n<p>HumanMessage(content&#061;&#034;\u6211\u53eb Alice&#xff0c;\u6211\u559c\u6b22\u732b&#034;)<\/p>\n<p>Bob \u7ebf\u7a0b\u5199\u5165&#xff1a;<\/p>\n<p>HumanMessage(content&#061;&#034;\u6211\u53eb Bob&#xff0c;\u6211\u559c\u6b22\u72d7&#034;)<\/p>\n<p>\u7531\u4e8e\u4e24\u6b21\u8c03\u7528\u4f7f\u7528\u4e0d\u540c\u7684 thread_id&#xff0c;Checkpointer \u4f1a\u4e3a\u5b83\u4eec\u5206\u522b\u7ef4\u62a4\u72ec\u7acb\u7684\u72b6\u6001\u94fe\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"431\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005008-6a7288c0f158d.png\" width=\"800\" \/><\/p>\n<p>\u4ee3\u7801\u968f\u540e\u5206\u522b\u8bfb\u53d6\u4e24\u4e2a\u7ebf\u7a0b\u7684\u6700\u65b0\u72b6\u6001&#xff1a;<\/p>\n<p>alice_state &#061; app.get_state(config_alice)<br \/>\nbob_state &#061; app.get_state(config_bob)<\/p>\n<p>\u8fd0\u884c\u7ed3\u679c&#xff1a;<\/p>\n<p>Alice \u6d88\u606f\u6570: 2<br \/>\nBob \u6d88\u606f\u6570: 2<br \/>\nAlice \u5bf9\u8bdd\u5305\u542b &#039;Alice&#039;: True<br \/>\nBob \u5bf9\u8bdd\u5305\u542b &#039;Bob&#039;: True<\/p>\n<p>\u6bcf\u6761\u7ebf\u7a0b\u4e2d\u90fd\u53ea\u6709&#xff1a;<\/p>\n<p>1 \u6761 HumanMessage<br \/>\n1 \u6761 AIMessage<\/p>\n<p>\u72b6\u6001\u6ca1\u6709\u4e92\u76f8\u6df7\u5165\u3002<\/p>\n<h5 id=\"%E7%BA%BF%E4%B8%8A%E7%8E%AF%E5%A2%83%E5%BA%94%E8%AF%A5%E5%A6%82%E4%BD%95%E8%AE%BE%E8%AE%A1%20thread_id%EF%BC%9F\">\u7ebf\u4e0a\u73af\u5883\u5e94\u8be5\u5982\u4f55\u8bbe\u8ba1 thread_id&#xff1f;<\/h5>\n<p>\u901a\u5e38\u4e0d\u8981\u76f4\u63a5\u628a thread_id \u5199\u6b7b\u6210&#xff1a;<\/p>\n<p>&#034;thread_id&#034;: &#034;default&#034;<\/p>\n<p>\u66f4\u7a33\u59a5\u7684\u65b9\u5f0f\u662f\u5c06\u7528\u6237\u6807\u8bc6\u548c\u4f1a\u8bdd\u6807\u8bc6\u7ec4\u5408\u8d77\u6765&#xff1a;<\/p>\n<p>thread_id &#061; f&#034;{user_id}:{conversation_id}&#034;<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\n<p>user_id \u7528\u4e8e\u533a\u5206\u7528\u6237&#xff1b;<\/p>\n<\/li>\n<li>\n<p>conversation_id \u7528\u4e8e\u533a\u5206\u540c\u4e00\u7528\u6237\u7684\u591a\u4e2a\u4f1a\u8bdd\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>u1001:conversation-001<br \/>\nu1001:conversation-002<br \/>\nu2048:conversation-001<\/p>\n<p>\u8fd9\u6837&#xff0c;\u540c\u4e00\u4e2a\u7528\u6237\u53ef\u4ee5\u62e5\u6709\u591a\u4e2a\u5f7c\u6b64\u9694\u79bb\u7684\u5bf9\u8bdd\u3002\u8fd8\u9700\u8981\u6ce8\u610f&#xff1a;<\/p>\n<p>thread_id \u662f\u72b6\u6001\u9694\u79bb\u6807\u8bc6&#xff0c;\u4e0d\u5e94\u76f4\u63a5\u627f\u62c5\u6743\u9650\u6821\u9a8c\u3002<\/p>\n<p>\u670d\u52a1\u7aef\u4ecd\u7136\u9700\u8981\u786e\u8ba4\u5f53\u524d\u8bf7\u6c42\u7528\u6237\u662f\u5426\u6709\u6743\u8bbf\u95ee\u8fd9\u4e2a thread_id&#xff0c;\u5426\u5219\u653b\u51fb\u8005\u53ea\u8981\u731c\u5230\u522b\u4eba\u7684\u7ebf\u7a0b\u6807\u8bc6&#xff0c;\u5c31\u53ef\u80fd\u5c1d\u8bd5\u8bfb\u53d6\u4e0d\u5c5e\u4e8e\u81ea\u5df1\u7684\u72b6\u6001\u3002<\/p>\n<h4 id=\"3.%20%E6%BC%94%E7%A4%BA%203%EF%BC%9A%E7%8A%B6%E6%80%81%E6%81%A2%E5%A4%8D\">3. \u6f14\u793a 3&#xff1a;\u72b6\u6001\u6062\u590d<\/h4>\n<p>\u7b2c\u4e09\u4e2a\u6f14\u793a\u5148\u4f7f\u7528 app1 \u5199\u5165\u4e24\u8f6e\u5bf9\u8bdd&#xff1a;<\/p>\n<p>app1.invoke(<br \/>\n    {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u8bb0\u4f4f&#xff1a;\u6211\u7684\u5bc6\u7801\u63d0\u793a\u662f&#039;\u84dd\u8272\u7684\u5929\u7a7a&#039;&#034;)], &#034;turn_count&#034;: 0},<br \/>\n    config&#061;config,<br \/>\n)<br \/>\napp1.invoke(<br \/>\n    {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u6211\u6700\u559c\u6b22\u7684\u7f16\u7a0b\u8bed\u8a00\u662f Rust&#034;)], &#034;turn_count&#034;: 0},<br \/>\n    config&#061;config,<br \/>\n)<\/p>\n<p>\u8fd9\u65f6&#xff0c;Checkpoint \u4e2d\u5171\u6709 4 \u6761\u6d88\u606f&#xff1a;<\/p>\n<p>Human&#xff1a;\u8bb0\u4f4f&#xff0c;\u6211\u7684\u5bc6\u7801\u63d0\u793a\u662f\u201c\u84dd\u8272\u7684\u5929\u7a7a\u201d<br \/>\nAI&#xff1a;\u2026\u2026<br \/>\nHuman&#xff1a;\u6211\u6700\u559c\u6b22\u7684\u7f16\u7a0b\u8bed\u8a00\u662f Rust<br \/>\nAI&#xff1a;\u2026\u2026<\/p>\n<p>\u63a5\u7740&#xff0c;\u4ee3\u7801\u91cd\u65b0\u7f16\u8bd1\u51fa\u4e00\u4e2a\u65b0\u7684 app2&#xff1a;<\/p>\n<p>app2 &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>\u56e0\u4e3a app1 \u548c app2 \u4f7f\u7528\u7684\u662f\u540c\u4e00\u4e2a checkpointer \u5b9e\u4f8b&#xff0c;\u6240\u4ee5 app2 \u80fd\u591f\u8bfb\u53d6 app1 \u5df2\u7ecf\u4fdd\u5b58\u7684\u72b6\u6001\u3002<\/p>\n<p>\u968f\u540e\u63d0\u95ee&#xff1a;<\/p>\n<p>result &#061; app2.invoke(<br \/>\n    {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u6211\u6700\u559c\u6b22\u4ec0\u4e48\u7f16\u7a0b\u8bed\u8a00&#xff1f;&#034;)], &#034;turn_count&#034;: 0},<br \/>\n    config&#061;config,<br \/>\n)<\/p>\n<p>\u6a21\u578b\u80fd\u591f\u4ece\u6062\u590d\u540e\u7684\u6d88\u606f\u5386\u53f2\u4e2d\u627e\u5230\u7b54\u6848&#xff1a;<\/p>\n<p>\u52a9\u624b&#xff1a;\u4f60\u6700\u559c\u6b22\u7684\u662f Rust\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"415\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005009-6a7288c1a905f.png\" width=\"800\" \/><\/p>\n<h5 id=\"%E4%B8%80%E4%B8%AA%E5%BF%85%E9%A1%BB%E8%AE%B2%E6%B8%85%E6%A5%9A%E7%9A%84%E7%BB%86%E8%8A%82\">\u4e00\u4e2a\u5fc5\u987b\u8bb2\u6e05\u695a\u7684\u7ec6\u8282<\/h5>\n<p>\u539f\u4ee3\u7801\u4e2d\u7684\u65e5\u5fd7\u63cf\u8ff0\u662f&#xff1a;<\/p>\n<p>log_step(logger, &#034;\u9636\u6bb5 2&#034;, &#034;\u6a21\u62df\u8fdb\u7a0b\u91cd\u542f \u2014 \u7528\u540c\u4e00\u4e2a checkpointer \u521b\u5efa\u65b0\u7684 app&#034;)<\/p>\n<p>\u8fd9\u91cc\u7684\u201c\u6a21\u62df\u8fdb\u7a0b\u91cd\u542f\u201d\u4e0d\u80fd\u6309\u5b57\u9762\u7406\u89e3\u6210\u771f\u6b63\u6740\u6389\u5e76\u91cd\u542f Python \u8fdb\u7a0b\u3002<\/p>\n<p>\u4ee3\u7801\u5b9e\u9645\u6a21\u62df\u7684\u662f&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\">\u91cd\u65b0\u521b\u5efa\u7f16\u8bd1\u540e\u7684 Graph \u5e94\u7528&#xff0c;\u4f46\u4ecd\u7136\u590d\u7528\u539f\u6765\u7684 MemorySaver \u5bf9\u8c61\u3002<\/span><\/p>\n<p>\u53ea\u8981\u4e0b\u9762\u8fd9\u4e2a\u5bf9\u8c61\u8fd8\u5728\u5185\u5b58\u4e2d&#xff1a;<\/p>\n<p>checkpointer &#061; MemorySaver()<\/p>\n<p>\u72b6\u6001\u5c31\u8fd8\u5728\u3002<\/p>\n<p>\u4f46\u771f\u6b63\u7ed3\u675f Python \u8fdb\u7a0b\u540e&#xff1a;<\/p>\n<p>Python \u8fdb\u7a0b\u9000\u51fa<br \/>\n    \u2193<br \/>\nMemorySaver \u5bf9\u8c61\u9500\u6bc1<br \/>\n    \u2193<br \/>\n\u6240\u6709\u5185\u5b58 Checkpoint \u6d88\u5931<\/p>\n<p>\u6240\u4ee5\u8fd9\u4e2a Demo \u8bc1\u660e\u7684\u662f&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\">\u53ea\u8981\u65b0\u7684 Graph \u5e94\u7528\u80fd\u591f\u8bbf\u95ee\u540c\u4e00\u4e2a Checkpointer \u540e\u7aef&#xff0c;\u5c31\u53ef\u4ee5\u6062\u590d\u539f\u6709\u72b6\u6001\u3002<\/span><\/p>\n<p>\u5b83\u6ca1\u6709\u8bc1\u660e&#xff1a;<\/p>\n<p>MemorySaver \u53ef\u4ee5\u8de8\u8fdb\u7a0b\u91cd\u542f\u4fdd\u5b58\u6570\u636e\u3002<\/p>\n<p>\u771f\u6b63\u9700\u8981\u8de8\u8fdb\u7a0b\u3001\u8de8\u673a\u5668\u6216\u8de8\u90e8\u7f72\u6062\u590d\u65f6&#xff0c;\u5fc5\u987b\u4f7f\u7528\u5916\u90e8\u6301\u4e45\u5316\u540e\u7aef&#xff0c;\u4f8b\u5982 SQLite\u3001PostgreSQL \u6216 Redis\u3002<\/p>\n<h4 id=\"4.%20%E6%BC%94%E7%A4%BA%204%EF%BC%9A%E6%9F%A5%E7%9C%8B%20Checkpoint%20%E5%8E%86%E5%8F%B2\">4. \u6f14\u793a 4&#xff1a;\u67e5\u770b Checkpoint \u5386\u53f2<\/h4>\n<p>\u4ee3\u7801\u8fde\u7eed\u8c03\u7528\u4e09\u6b21 Graph&#xff1a;<\/p>\n<p>steps &#061; [&#034;\u7b2c\u4e00\u6b65&#034;, &#034;\u7b2c\u4e8c\u6b65&#034;, &#034;\u7b2c\u4e09\u6b65&#034;]<br \/>\nfor step in steps:<br \/>\n    app.invoke(<br \/>\n        {&#034;messages&#034;: [HumanMessage(content&#061;f&#034;\u8fd9\u662f{step}&#034;)], &#034;turn_count&#034;: 0},<br \/>\n        config&#061;config,<br \/>\n    )<\/p>\n<p>\u968f\u540e\u904d\u5386\u5386\u53f2\u72b6\u6001&#xff1a;<\/p>\n<p>for state in app.get_state_history(config):<br \/>\n    history_count &#043;&#061; 1<br \/>\n    msg_count &#061; len(state.values.get(&#034;messages&#034;, []))<br \/>\n    ts &#061; state.config.get(&#034;configurable&#034;, {}).get(&#034;checkpoint_id&#034;, &#034;N\/A&#034;)<br \/>\n    print(f&#034;    \u7248\u672c {history_count}: {msg_count} \u6761\u6d88\u606f, checkpoint_id&#061;{ts[:20]}&#8230;&#034;)<\/p>\n<p>\u8f93\u51fa\u7c7b\u4f3c&#xff1a;<\/p>\n<p>\u7248\u672c 1: 6 \u6761\u6d88\u606f<br \/>\n\u7248\u672c 2: 5 \u6761\u6d88\u606f<br \/>\n\u7248\u672c 3: 4 \u6761\u6d88\u606f<br \/>\n\u7248\u672c 4: 4 \u6761\u6d88\u606f<br \/>\n\u7248\u672c 5: 3 \u6761\u6d88\u606f<br \/>\n\u7248\u672c 6: 2 \u6761\u6d88\u606f<\/p>\n<h5 id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%89%E6%AC%A1%20invoke%20%E4%BC%9A%E6%9C%89%E5%85%AD%E4%B8%AA%E4%BB%A5%E4%B8%8A%E7%9A%84%E7%89%88%E6%9C%AC%EF%BC%9F\">\u4e3a\u4ec0\u4e48\u4e09\u6b21 invoke \u4f1a\u6709\u516d\u4e2a\u4ee5\u4e0a\u7684\u7248\u672c&#xff1f;<\/h5>\n<p>\u56e0\u4e3a Checkpoint \u5e76\u4e0d\u662f\u201c\u6bcf\u6b21 invoke \u53ea\u4fdd\u5b58\u4e00\u6b21\u201d\u3002LangGraph \u4f1a\u5728 super-step \u8fb9\u754c\u4fdd\u5b58\u72b6\u6001\u3002\u5bf9\u4e8e\u672c\u6587\u8fd9\u4e2a\u53ea\u6709\u4e00\u4e2a chat \u8282\u70b9\u7684\u7ebf\u6027 Graph&#xff0c;\u4e00\u6b21\u8c03\u7528\u901a\u5e38\u81f3\u5c11\u4f1a\u7ecf\u5386&#xff1a;<\/p>\n<p>\u8f93\u5165\u88ab\u5199\u5165\u72b6\u6001<br \/>\n    \u2193<br \/>\nchat \u8282\u70b9\u6267\u884c\u5b8c\u6210<\/p>\n<p>\u56e0\u6b64\u5386\u53f2\u4e2d\u53ef\u80fd\u540c\u65f6\u51fa\u73b0&#xff1a;<\/p>\n<p>5 \u6761\u6d88\u606f&#xff1a;\u65b0 HumanMessage \u5df2\u5199\u5165&#xff0c;AIMessage \u5c1a\u672a\u751f\u6210<br \/>\n6 \u6761\u6d88\u606f&#xff1a;chat_node \u5df2\u5b8c\u6210&#xff0c;AIMessage \u5df2\u5199\u5165<\/p>\n<p>\u8fd9\u6b63\u597d\u89e3\u91ca\u4e86\u5386\u53f2\u8f93\u51fa\u4e2d\u7684&#xff1a;<\/p>\n<p>6 \u2192 5 \u2192 4 \u2192 4 \u2192 3 \u2192 2<\/p>\n<p>\u5176\u4e2d\u91cd\u590d\u7684 4 \u5e76\u4e0d\u8868\u793a\u91cd\u590d\u4fdd\u5b58\u4e86\u5b8c\u5168\u76f8\u540c\u7684\u6267\u884c\u4f4d\u7f6e&#xff0c;\u800c\u53ef\u80fd\u5206\u522b\u5bf9\u5e94&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e0a\u4e00\u8f6e\u6267\u884c\u5b8c\u6210\u540e\u7684\u72b6\u6001&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4e0b\u4e00\u8f6e\u8f93\u5165\u8fdb\u5165\u4e4b\u524d\u6216\u4e4b\u540e\u7684\u72b6\u6001\u8fb9\u754c\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"%E5%8E%86%E5%8F%B2%E9%A1%BA%E5%BA%8F%E4%B9%9F%E8%A6%81%E6%B3%A8%E6%84%8F\">\u5386\u53f2\u987a\u5e8f\u4e5f\u8981\u6ce8\u610f<\/h5>\n<p>get_state_history(config) \u9ed8\u8ba4\u6309\u5012\u5e8f\u8fd4\u56de\u72b6\u6001&#xff1a;<\/p>\n<p>\u6700\u65b0 Checkpoint<br \/>\n    \u2193<br \/>\n\u66f4\u65e9\u7684 Checkpoint<br \/>\n    \u2193<br \/>\n\u6700\u521d\u7684 Checkpoint<\/p>\n<p>\u56e0\u6b64\u8f93\u51fa\u4e2d\u7684\u201c\u7248\u672c 1\u201d\u5b9e\u9645\u4e0a\u662f\u6700\u65b0\u72b6\u6001&#xff0c;\u800c\u4e0d\u662f\u6700\u8001\u72b6\u6001\u3002\u5b98\u65b9\u65f6\u95f4\u65c5\u884c\u6587\u6863\u4e5f\u660e\u786e\u8bf4\u660e&#xff0c;get_state_history() \u8fd4\u56de\u7684\u662f\u9006\u65f6\u95f4\u987a\u5e8f\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E4%BB%8E%E5%8E%86%E5%8F%B2%20Checkpoint%20%E6%81%A2%E5%A4%8D%EF%BC%8C%E4%B8%8D%E7%AD%89%E4%BA%8E%E8%AF%BB%E5%8F%96%E7%BC%93%E5%AD%98\">&#xff08;\u4e09&#xff09;\u4ece\u5386\u53f2 Checkpoint \u6062\u590d&#xff0c;\u4e0d\u7b49\u4e8e\u8bfb\u53d6\u7f13\u5b58<\/h3>\n<p>Checkpoint \u5386\u53f2\u4e0d\u4ec5\u53ef\u4ee5\u67e5\u770b&#xff0c;\u8fd8\u53ef\u4ee5\u7528\u4e8e Replay \u548c Fork\u3002\u4f46\u8fd9\u91cc\u6709\u4e00\u4e2a\u91cd\u8981\u533a\u522b&#xff1a;<\/p>\n<h4 id=\"1.%20%E6%9F%A5%E7%9C%8B%E5%8E%86%E5%8F%B2%E7%8A%B6%E6%80%81\">1. \u67e5\u770b\u5386\u53f2\u72b6\u6001<\/h4>\n<p>history &#061; list(app.get_state_history(config))<\/p>\n<p>\u53ea\u662f\u8bfb\u53d6\u5386\u53f2 StateSnapshot&#xff0c;\u4e0d\u4f1a\u91cd\u65b0\u8c03\u7528\u6a21\u578b\u6216\u5de5\u5177\u3002<\/p>\n<h4 id=\"2.%20%E4%BB%8E%E5%8E%86%E5%8F%B2%E7%8A%B6%E6%80%81%E9%87%8D%E6%96%B0%E6%89%A7%E8%A1%8C\">2. \u4ece\u5386\u53f2\u72b6\u6001\u91cd\u65b0\u6267\u884c<\/h4>\n<p>\u5982\u679c\u4f7f\u7528\u67d0\u4e2a\u5386\u53f2 Checkpoint \u7684 config \u518d\u6b21\u8c03\u7528 Graph&#xff0c;Checkpoint \u4e4b\u524d\u7684\u6b65\u9aa4\u4e0d\u4f1a\u91cd\u65b0\u8fd0\u884c&#xff0c;\u4f46\u5176\u540e\u7684\u8282\u70b9\u4f1a\u518d\u6b21\u6267\u884c\u3002<\/p>\n<p>\u8fd9\u610f\u5473\u7740&#xff1a;<\/p>\n<ul>\n<li>\n<p>LLM \u53ef\u80fd\u4ea7\u751f\u4e0d\u540c\u56de\u7b54&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5916\u90e8 API \u4f1a\u518d\u6b21\u8bf7\u6c42&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5de5\u5177\u8c03\u7528\u53ef\u80fd\u4ea7\u751f\u65b0\u7684\u526f\u4f5c\u7528&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Human-in-the-loop \u4e2d\u65ad\u53ef\u80fd\u518d\u6b21\u89e6\u53d1\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5b98\u65b9\u6587\u6863\u7279\u522b\u63d0\u9192&#xff1a;Replay \u4f1a\u91cd\u65b0\u6267\u884c Checkpoint \u540e\u9762\u7684\u8282\u70b9&#xff0c;\u800c\u4e0d\u662f\u7b80\u5355\u5730\u4ece\u7f13\u5b58\u4e2d\u8bfb\u53d6\u65e7\u7ed3\u679c\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u652f\u6301\u65f6\u95f4\u65c5\u884c\u7684\u751f\u4ea7 Agent \u5fc5\u987b\u8003\u8651\u8282\u70b9\u7684\u5e42\u7b49\u6027\u3002\u4f8b\u5982&#xff0c;\u4e0b\u9762\u8fd9\u4e9b\u64cd\u4f5c\u4e0d\u80fd\u5728 Replay \u65f6\u65e0\u6761\u4ef6\u91cd\u590d&#xff1a;<\/p>\n<p>\u53d1\u9001\u4ed8\u6b3e<br \/>\n\u53d1\u9001\u90ae\u4ef6<br \/>\n\u521b\u5efa\u8ba2\u5355<br \/>\n\u5220\u9664\u6570\u636e<br \/>\n\u8c03\u7528\u4e0d\u53ef\u9006\u7684\u7b2c\u4e09\u65b9\u63a5\u53e3<\/p>\n<p>\u66f4\u7a33\u59a5\u7684\u505a\u6cd5\u662f\u4e3a\u526f\u4f5c\u7528\u64cd\u4f5c\u589e\u52a0\u4e1a\u52a1\u5e42\u7b49\u952e\u3002<\/p>\n<h2 id=\"%E4%BA%94%E3%80%81Checkpoint%20%E4%B8%8E%20Store%20%E4%B8%8D%E8%A6%81%E6%B7%B7%E4%B8%BA%E4%B8%80%E8%B0%88\">\u4e94\u3001Checkpoint \u4e0e Store \u4e0d\u8981\u6df7\u4e3a\u4e00\u8c08<\/h2>\n<p>\u5f88\u591a\u6587\u7ae0\u4f1a\u7b3c\u7edf\u5730\u628a\u4e24\u8005\u90fd\u53eb\u4f5c\u201cAgent \u8bb0\u5fc6\u201d&#xff0c;\u4f46\u5b83\u4eec\u89e3\u51b3\u7684\u95ee\u9898\u4e0d\u540c\u3002<\/p>\n<table>\n<tr>\u7ef4\u5ea6CheckpointerStore<\/tr>\n<tbody>\n<tr>\n<td>\u4fdd\u5b58\u5185\u5bb9<\/td>\n<td>Graph State \u5feb\u7167<\/td>\n<td>\u5e94\u7528\u5b9a\u4e49\u7684\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u4f5c\u7528\u8303\u56f4<\/td>\n<td>\u5355\u4e2a thread<\/td>\n<td>\u53ef\u8de8 thread<\/td>\n<\/tr>\n<tr>\n<td>\u5e38\u89c1\u6570\u636e<\/td>\n<td>\u6d88\u606f\u3001\u8282\u70b9\u72b6\u6001\u3001\u6267\u884c\u8fdb\u5ea6<\/td>\n<td>\u7528\u6237\u504f\u597d\u3001\u957f\u671f\u4e8b\u5b9e\u3001\u77e5\u8bc6\u6761\u76ee<\/td>\n<\/tr>\n<tr>\n<td>\u4e3b\u8981\u7528\u9014<\/td>\n<td>\u591a\u8f6e\u5bf9\u8bdd\u3001\u6062\u590d\u3001\u56de\u6eaf\u3001\u6545\u969c\u7eed\u8dd1<\/td>\n<td>\u957f\u671f\u8bb0\u5fc6\u3001\u7528\u6237\u753b\u50cf\u3001\u5171\u4eab\u77e5\u8bc6<\/td>\n<\/tr>\n<tr>\n<td>\u8bbf\u95ee\u65b9\u5f0f<\/td>\n<td>\u5728 config \u4e2d\u4f20\u5165 thread_id<\/td>\n<td>\u901a\u8fc7\u547d\u540d\u7a7a\u95f4\u548c key \u8bfb\u5199<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>\u201c\u8fd9\u8f6e\u5bf9\u8bdd\u91cc&#xff0c;\u7528\u6237\u521a\u4e0a\u4f20\u4e86\u4e00\u4e2a\u6587\u4ef6\u201d<\/p>\n<p>\u9002\u5408\u653e\u5165\u5f53\u524d\u7ebf\u7a0b\u7684 State\u3002\u800c&#xff1a;<\/p>\n<p>\u201c\u7528\u6237\u957f\u671f\u504f\u597d\u4f7f\u7528\u6df1\u8272\u4e3b\u9898\u201d<\/p>\n<p>\u66f4\u9002\u5408\u653e\u5165 Store\u3002<\/p>\n<p>\u5b98\u65b9\u6587\u6863\u5c06 Checkpointer \u5b9a\u4e49\u4e3a thread-scoped short-term memory&#xff0c;\u5c06 Store \u5b9a\u4e49\u4e3a\u8de8\u7ebf\u7a0b\u7684\u957f\u671f\u6570\u636e\u5b58\u50a8\u3002<\/p>\n<h2 id=\"%E5%85%AD%E3%80%81%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E8%AF%B4%E6%98%8E%E5%8F%8A%E7%BA%BF%E4%B8%8A%E8%80%83%E8%99%91%E5%9F%BA%E6%9C%AC%E7%82%B9%E8%AF%B4%E6%98%8E\" style=\"background-color:transparent\">\u516d\u3001\u5e38\u89c1\u95ee\u9898\u6392\u67e5\u8bf4\u660e\u53ca\u7ebf\u4e0a\u8003\u8651\u57fa\u672c\u70b9\u8bf4\u660e<\/h2>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B8%8E%E6%8E%92%E6%9F%A5%E6%96%B9%E5%BC%8F\">&#xff08;\u4e00&#xff09;\u5e38\u89c1\u95ee\u9898\u4e0e\u6392\u67e5\u65b9\u5f0f<\/h3>\n<h4 id=\"1.%20%E9%97%AE%E9%A2%98%201%EF%BC%9A%E5%BF%98%E8%AE%B0%E4%BC%A0%E5%85%A5%20thread_id\">1. \u95ee\u9898 1&#xff1a;\u5fd8\u8bb0\u4f20\u5165 thread_id<\/h4>\n<p>\u9519\u8bef\u8c03\u7528&#xff1a;<\/p>\n<p>app.invoke({&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u4f60\u597d&#034;)]})<\/p>\n<p>\u6302\u8f7d Checkpointer \u540e&#xff0c;\u6bcf\u6b21\u8c03\u7528\u90fd\u5e94\u8be5\u5e26\u4e0a&#xff1a;<\/p>\n<p>config &#061; {<br \/>\n    &#034;configurable&#034;: {<br \/>\n        &#034;thread_id&#034;: &#034;some-thread-id&#034;<br \/>\n    }<br \/>\n}<\/p>\n<p>\u5426\u5219 Checkpointer \u65e0\u6cd5\u786e\u5b9a\u72b6\u6001\u5c5e\u4e8e\u54ea\u4e2a\u7ebf\u7a0b\u3002<\/p>\n<h4 id=\"2.%20%E9%97%AE%E9%A2%98%202%EF%BC%9A%E6%9C%8D%E5%8A%A1%E9%87%8D%E5%90%AF%E5%90%8E%20MemorySaver%20%E7%8A%B6%E6%80%81%E6%B6%88%E5%A4%B1\">2. \u95ee\u9898 2&#xff1a;\u670d\u52a1\u91cd\u542f\u540e MemorySaver \u72b6\u6001\u6d88\u5931<\/h4>\n<p>\u8fd9\u662f\u6b63\u5e38\u884c\u4e3a\u3002MemorySaver \u7684\u6570\u636e\u53ea\u5b58\u5728\u4e8e\u5f53\u524d Python \u8fdb\u7a0b\u4e2d\u3002<\/p>\n<p>\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<p>\u5b66\u4e60 \/ Demo \/ \u6d4b\u8bd5 \/ \u672c\u5730\u8c03\u8bd5<\/p>\n<p>\u4e0d\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<p>\u751f\u4ea7\u670d\u52a1 \/ \u591a\u8fdb\u7a0b\u90e8\u7f72 \/ \u5bb9\u5668\u6eda\u52a8\u53d1\u5e03 \/ \u8de8\u673a\u5668\u6062\u590d<\/p>\n<p>\u751f\u4ea7\u73af\u5883\u5e94\u4f7f\u7528\u5916\u90e8\u6301\u4e45\u5316 Checkpointer\u3002<\/p>\n<h4 id=\"3.%20%E9%97%AE%E9%A2%98%203%EF%BC%9A%E4%B8%8D%E5%90%8C%E7%94%A8%E6%88%B7%E7%9A%84%E5%AF%B9%E8%AF%9D%E5%8F%91%E7%94%9F%E4%B8%B2%E5%8F%B0\">3. \u95ee\u9898 3&#xff1a;\u4e0d\u540c\u7528\u6237\u7684\u5bf9\u8bdd\u53d1\u751f\u4e32\u53f0<\/h4>\n<p>\u6700\u5e38\u89c1\u539f\u56e0\u662f\u6240\u6709\u8bf7\u6c42\u4f7f\u7528\u4e86\u540c\u4e00\u4e2a\u56fa\u5b9a\u503c&#xff1a;<\/p>\n<p>&#034;thread_id&#034;: &#034;default&#034;<\/p>\n<p>\u7ed3\u679c\u662f\u6240\u6709\u7528\u6237\u90fd\u5728\u8bfb\u5199\u540c\u4e00\u6761\u72b6\u6001\u94fe\u3002\u63a8\u8350\u81f3\u5c11\u5305\u542b&#xff1a;<\/p>\n<p>user_id &#043; conversation_id<\/p>\n<p>\u5e76\u5728\u670d\u52a1\u7aef\u9a8c\u8bc1\u7ebf\u7a0b\u5f52\u5c5e\u5173\u7cfb\u3002<\/p>\n<h4 id=\"4.%20%E9%97%AE%E9%A2%98%204%EF%BC%9A%E6%B6%88%E6%81%AF%E8%83%BD%E5%A4%9F%E7%B4%AF%E7%A7%AF%EF%BC%8C%E6%99%AE%E9%80%9A%E5%AD%97%E6%AE%B5%E5%8D%B4%E6%B2%A1%E6%9C%89%E7%B4%AF%E7%A7%AF\">4. \u95ee\u9898 4&#xff1a;\u6d88\u606f\u80fd\u591f\u7d2f\u79ef&#xff0c;\u666e\u901a\u5b57\u6bb5\u5374\u6ca1\u6709\u7d2f\u79ef<\/h4>\n<p>Checkpoint \u53ea\u8d1f\u8d23\u6062\u590d\u72b6\u6001\u3002\u5b57\u6bb5\u7a76\u7adf\u662f\u8ffd\u52a0\u3001\u6c42\u548c\u3001\u5408\u5e76\u8fd8\u662f\u8986\u76d6&#xff0c;\u7531 Reducer \u51b3\u5b9a\u3002<\/p>\n<p>\u672c\u6587\u4e2d&#xff1a;<\/p>\n<p>messages: Annotated[list[BaseMessage], add_messages]<\/p>\n<p>\u4f1a\u8ffd\u52a0\u6d88\u606f\u3002\u800c&#xff1a;<\/p>\n<p>turn_count: int<\/p>\n<p>\u9ed8\u8ba4\u4f1a\u88ab\u65b0\u8f93\u5165\u8986\u76d6\u3002\u56e0\u6b64&#xff0c;\u8bbe\u8ba1 State \u65f6\u4e0d\u80fd\u53ea\u5173\u6ce8\u5b57\u6bb5\u7c7b\u578b&#xff0c;\u8fd8\u8981\u5173\u6ce8\u5b57\u6bb5\u66f4\u65b0\u8bed\u4e49\u3002<\/p>\n<h4 id=\"5.%20%E9%97%AE%E9%A2%98%205%EF%BC%9A%E4%BF%AE%E6%94%B9%20State%20%E5%90%8E%EF%BC%8C%E6%97%A7%20Checkpoint%20%E5%87%BA%E7%8E%B0%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98\">5. \u95ee\u9898 5&#xff1a;\u4fee\u6539 State \u540e&#xff0c;\u65e7 Checkpoint \u51fa\u73b0\u517c\u5bb9\u95ee\u9898<\/h4>\n<p>\u751f\u4ea7\u7cfb\u7edf\u4e2d\u7684 State Schema \u4f1a\u968f\u7740\u4e1a\u52a1\u8fed\u4ee3\u53d1\u751f\u53d8\u5316&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>v1:<br \/>\nmessages<br \/>\nturn_count<\/p>\n<p>\u5347\u7ea7\u540e\u53d8\u6210&#xff1a;<\/p>\n<p>v2:<br \/>\nmessages<br \/>\nturn_count<br \/>\nuser_profile<br \/>\nworkflow_status<\/p>\n<p>\u5982\u679c\u65b0\u4ee3\u7801\u76f4\u63a5\u5047\u8bbe\u6240\u6709\u5386\u53f2\u72b6\u6001\u90fd\u6709\u65b0\u5b57\u6bb5&#xff0c;\u5c31\u53ef\u80fd\u5728\u6062\u590d\u65e7\u7ebf\u7a0b\u65f6\u62a5\u9519\u3002<\/p>\n<p>\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u7b56\u7565&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u65b0\u5b57\u6bb5\u63d0\u4f9b\u9ed8\u8ba4\u503c&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8bfb\u53d6\u65f6\u4f7f\u7528 state.get()&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5728 State \u4e2d\u589e\u52a0 schema_version&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u7f16\u5199\u8fc1\u79fb\u903b\u8f91&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u91cd\u5927\u4e0d\u517c\u5bb9\u5347\u7ea7\u65f6\u521b\u5efa\u65b0\u7684\u7ebf\u7a0b\u547d\u540d\u7a7a\u95f4\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"6.%20%E9%97%AE%E9%A2%98%206%EF%BC%9ACheckpoint%20%E8%B6%8A%E7%A7%AF%E8%B6%8A%E5%A4%9A\">6. \u95ee\u9898 6&#xff1a;Checkpoint \u8d8a\u79ef\u8d8a\u591a<\/h4>\n<p>\u957f\u65f6\u95f4\u8fd0\u884c\u7684 Agent \u53ef\u80fd\u4ea7\u751f\u5927\u91cf\u7248\u672c\u3002\u800c\u4e14\u8981\u533a\u5206\u4e24\u4ef6\u4e8b&#xff1a;<\/p>\n<h5 id=\"%E8%A3%81%E5%89%AA%E6%A8%A1%E5%9E%8B%E4%B8%8A%E4%B8%8B%E6%96%87\">\u88c1\u526a\u6a21\u578b\u4e0a\u4e0b\u6587<\/h5>\n<p>\u51cf\u5c11\u53d1\u9001\u7ed9 LLM \u7684\u6d88\u606f\u6570\u91cf&#xff0c;\u63a7\u5236 Token \u6210\u672c\u3002<\/p>\n<h5 id=\"%E6%B8%85%E7%90%86%20Checkpoint%20%E5%8E%86%E5%8F%B2\">\u6e05\u7406 Checkpoint \u5386\u53f2<\/h5>\n<p>\u51cf\u5c11\u6301\u4e45\u5316\u540e\u7aef\u4e2d\u7684\u5386\u53f2\u72b6\u6001\u7248\u672c&#xff0c;\u63a7\u5236\u5b58\u50a8\u6210\u672c\u3002\u53ea\u88c1\u526a\u4e0a\u4e0b\u6587&#xff0c;\u4e0d\u4e00\u5b9a\u4f1a\u5220\u9664\u5df2\u7ecf\u4fdd\u5b58\u7684\u5386\u53f2 Checkpoint\u3002<\/p>\n<p>\u751f\u4ea7\u73af\u5883\u9700\u8981\u5355\u72ec\u8bbe\u8ba1&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6570\u636e\u4fdd\u7559\u5468\u671f&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6700\u8fd1\u7248\u672c\u4fdd\u7559\u6570\u91cf&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u51b7\u70ed\u6570\u636e\u5206\u5c42&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f1a\u8bdd\u5f52\u6863&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u7528\u6237\u5220\u9664\u6570\u636e\u6d41\u7a0b\u3002<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E8%BF%98%E9%9C%80%E8%A6%81%E8%80%83%E8%99%91%E4%BB%80%E4%B9%88%EF%BC%9F\">&#xff08;\u4e8c&#xff09;\u751f\u4ea7\u73af\u5883\u8fd8\u9700\u8981\u8003\u8651\u4ec0\u4e48&#xff1f;<\/h3>\n<h4 id=\"1.%20%E6%8C%81%E4%B9%85%E5%8C%96%E5%90%8E%E7%AB%AF\">1. \u6301\u4e45\u5316\u540e\u7aef<\/h4>\n<p>\u751f\u4ea7\u73af\u5883\u7684\u5173\u952e\u8981\u6c42\u4e0d\u662f\u201c\u5bf9\u8c61\u80fd\u590d\u7528\u201d&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<p>\u8fdb\u7a0b\u9000\u51fa\u540e&#xff0c;\u72b6\u6001\u4ecd\u7136\u5b58\u5728<\/p>\n<p>\u8fd8\u8981\u652f\u6301&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u591a\u5b9e\u4f8b\u8bbf\u95ee&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5931\u8d25\u91cd\u8bd5&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8fde\u63a5\u6c60&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5907\u4efd\u6062\u590d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u6e05\u7406&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6743\u9650\u63a7\u5236&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u76d1\u63a7\u544a\u8b66\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"2.%20%E5%90%8C%E4%B8%80%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%B9%B6%E5%8F%91%E8%B0%83%E7%94%A8\">2. \u540c\u4e00\u7ebf\u7a0b\u7684\u5e76\u53d1\u8c03\u7528<\/h4>\n<p>\u5047\u8bbe\u540c\u4e00\u4e2a thread_id \u540c\u65f6\u6536\u5230\u4e24\u4e2a\u8bf7\u6c42&#xff1a;<\/p>\n<p>\u8bf7\u6c42 A&#xff1a;\u7528\u6237\u4e0a\u4f20\u4e86\u4e00\u4efd\u5408\u540c<br \/>\n\u8bf7\u6c42 B&#xff1a;\u7528\u6237\u8be2\u95ee\u4e0a\u4e00\u4efd\u5408\u540c\u7684\u7ed3\u8bba<\/p>\n<p>\u5982\u679c\u4e24\u4e2a\u8bf7\u6c42\u540c\u65f6\u6062\u590d\u540c\u4e00\u4e2a\u65e7\u7248\u672c&#xff0c;\u518d\u5404\u81ea\u5199\u56de\u65b0\u72b6\u6001&#xff0c;\u5c31\u53ef\u80fd\u4ea7\u751f\u5e76\u53d1\u51b2\u7a81\u3002<\/p>\n<p>\u5e38\u89c1\u89e3\u51b3\u65b9\u5f0f\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u540c\u4e00 thread_id \u4e32\u884c\u6267\u884c&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u5206\u5e03\u5f0f\u9501&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u4efb\u52a1\u961f\u5217&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u4e50\u89c2\u5e76\u53d1\u63a7\u5236&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u68c0\u6d4b Checkpoint \u7248\u672c\u51b2\u7a81\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"3.%20%E8%8A%82%E7%82%B9%E5%B9%82%E7%AD%89%E6%80%A7\">3. \u8282\u70b9\u5e42\u7b49\u6027<\/h4>\n<p>\u6709\u4e86 Checkpoint \u4e4b\u540e&#xff0c;\u8282\u70b9\u53ef\u80fd\u56e0\u4e3a\u4ee5\u4e0b\u539f\u56e0\u91cd\u65b0\u6267\u884c&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6545\u969c\u6062\u590d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Retry&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Replay&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Time Travel&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4eba\u5de5\u4fee\u6539\u72b6\u6001\u540e\u7eed\u8dd1\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u7eaf\u8ba1\u7b97\u8282\u70b9\u901a\u5e38\u6ca1\u6709\u95ee\u9898\u3002\u6d89\u53ca\u771f\u5b9e\u526f\u4f5c\u7528\u7684\u8282\u70b9\u9700\u8981\u683c\u5916\u8c28\u614e&#xff1a;<\/p>\n<p>\u652f\u4ed8\u3001\u53d1\u4fe1\u3001\u5efa\u5355\u3001\u5220\u9664\u3001\u53d1\u5e03\u3001\u4fee\u6539\u5916\u90e8\u7cfb\u7edf<\/p>\n<p>\u63a8\u8350\u4e3a\u8fd9\u4e9b\u64cd\u4f5c\u4fdd\u5b58\u4e1a\u52a1\u6267\u884c\u6807\u8bc6&#xff0c;\u907f\u514d\u91cd\u590d\u6267\u884c\u3002<\/p>\n<h4 id=\"4.%20%E6%95%8F%E6%84%9F%E6%95%B0%E6%8D%AE%E4%BF%9D%E6%8A%A4\">4. \u654f\u611f\u6570\u636e\u4fdd\u62a4<\/h4>\n<p>\u672c\u6587\u4e3a\u4e86\u6f14\u793a\u72b6\u6001\u8bb0\u5fc6&#xff0c;\u4f7f\u7528\u4e86&#xff1a;<\/p>\n<p>\u5bc6\u7801\u63d0\u793a&#xff1a;\u84dd\u8272\u7684\u5929\u7a7a<\/p>\n<p>\u8fd9\u53ea\u662f\u6559\u5b66\u793a\u4f8b\u3002\u751f\u4ea7\u73af\u5883\u4e0d\u5e94\u5728\u6d88\u606f\u5386\u53f2\u6216 Checkpoint \u4e2d\u4fdd\u5b58&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u660e\u6587\u5bc6\u7801&#xff1b;<\/p>\n<\/li>\n<li>\n<p>API Key&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Access Token&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u79c1\u94a5&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5b8c\u6574\u652f\u4ed8\u4fe1\u606f&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u5fc5\u8981\u7684\u8eab\u4efd\u8bc1\u660e\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u9700\u8981\u4fdd\u5b58\u7684\u654f\u611f\u5b57\u6bb5\u5e94\u8fdb\u884c&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6700\u5c0f\u5316\u91c7\u96c6&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8131\u654f&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u52a0\u5bc6&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6743\u9650\u9694\u79bb&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u751f\u547d\u5468\u671f\u7ba1\u7406&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5ba1\u8ba1\u8bb0\u5f55\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"5.%20%E5%8F%AF%E8%A7%82%E6%B5%8B%E6%80%A7\">5. \u53ef\u89c2\u6d4b\u6027<\/h4>\n<p>\u5efa\u8bae\u5728\u65e5\u5fd7\u548c\u94fe\u8def\u8ffd\u8e2a\u4e2d\u8bb0\u5f55&#xff1a;<\/p>\n<p>thread_id<br \/>\ncheckpoint_id<br \/>\ncheckpoint_ns<br \/>\n\u6267\u884c\u8282\u70b9<br \/>\n\u6062\u590d\u6765\u6e90<br \/>\n\u5199\u5165\u8017\u65f6<br \/>\n\u72b6\u6001\u5927\u5c0f<br \/>\n\u5386\u53f2\u7248\u672c\u6570\u91cf<\/p>\n<p>\u4f46\u4e0d\u8981\u76f4\u63a5\u5c06\u5b8c\u6574\u6d88\u606f\u6216\u654f\u611f State \u65e0\u9650\u5236\u8f93\u51fa\u5230\u65e5\u5fd7\u3002<\/p>\n<h2 id=\"%E4%B8%83%E3%80%81%E5%A6%82%E4%BD%95%E8%AF%BB%E6%87%82%E6%9C%AC%E6%AC%A1%20Demo%20%E7%9A%84%E5%9B%9B%E4%B8%AA%E7%BB%93%E6%9E%9C%EF%BC%9F\" style=\"background-color:transparent\">\u4e03\u3001\u5982\u4f55\u8bfb\u61c2\u672c\u6b21 Demo \u7684\u56db\u4e2a\u7ed3\u679c&#xff1f;<\/h2>\n<table>\n<tr>\u6f14\u793a\u8bc1\u660e\u4e86\u4ec0\u4e48\u6ca1\u6709\u8bc1\u660e\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>\u57fa\u672c Checkpoint<\/td>\n<td>\u540c\u4e00\u7ebf\u7a0b\u7684\u6d88\u606f\u53ef\u4ee5\u6301\u7eed\u7d2f\u79ef<\/td>\n<td>\u666e\u901a\u5b57\u6bb5\u4f1a\u81ea\u52a8\u7d2f\u52a0<\/td>\n<\/tr>\n<tr>\n<td>Thread ID \u9694\u79bb<\/td>\n<td>\u4e0d\u540c\u7ebf\u7a0b\u7684\u72b6\u6001\u4e92\u4e0d\u5e72\u6270<\/td>\n<td>thread_id \u81ea\u52a8\u63d0\u4f9b\u8bbf\u95ee\u63a7\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u72b6\u6001\u6062\u590d<\/td>\n<td>\u65b0 app \u53ef\u4ece\u540c\u4e00\u4e2a Checkpointer \u6062\u590d<\/td>\n<td>MemorySaver \u80fd\u8de8\u8fdb\u7a0b\u91cd\u542f<\/td>\n<\/tr>\n<tr>\n<td>\u5386\u53f2\u7248\u672c<\/td>\n<td>\u53ef\u4ee5\u67e5\u770b\u591a\u4e2a StateSnapshot<\/td>\n<td>\u6bcf\u6b21 invoke \u53ea\u4ea7\u751f\u4e00\u4e2a\u7248\u672c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6700\u91cd\u8981\u7684\u56db\u4e2a\u7ed3\u8bba\u662f&#xff1a;<\/p>\n<li>\n<p>compile(checkpointer&#061;&#8230;) \u4e3a Graph \u63a5\u5165\u72b6\u6001\u4fdd\u5b58\u540e\u7aef\u3002<\/p>\n<\/li>\n<li>\n<p>thread_id \u51b3\u5b9a\u72b6\u6001\u5c5e\u4e8e\u54ea\u6761\u7ebf\u7a0b\u3002<\/p>\n<\/li>\n<li>\n<p>Reducer \u51b3\u5b9a\u65b0\u8f93\u5165\u5982\u4f55\u4e0e\u65e7\u72b6\u6001\u5408\u5e76\u3002<\/p>\n<\/li>\n<li>\n<p>MemorySaver \u53ea\u80fd\u5728\u5f53\u524d\u8fdb\u7a0b\u5b58\u6d3b\u671f\u95f4\u4fdd\u5b58\u6570\u636e\u3002<\/p>\n<\/li>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1200\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005010-6a7288c25dcd5.png\" width=\"800\" \/><\/p>\n<h2 id=\"%E5%85%AB%E3%80%81%E6%80%BB%E7%BB%93\">\u516b\u3001\u603b\u7ed3<\/h2>\n<p>\u8fd9\u4e00\u7bc7&#xff0c;\u6211\u4eec\u7528 MemorySaver \u7ed9 LangGraph Agent \u63a5\u5165\u4e86\u6700\u57fa\u7840\u7684 Checkpoint \u80fd\u529b\u3002<\/p>\n<p>\u5b83\u5e26\u6765\u7684\u4e0d\u53ea\u662f\u201c\u8bb0\u4f4f\u804a\u5929\u8bb0\u5f55\u201d&#xff0c;\u800c\u662f\u5b8c\u6574\u7684\u7ebf\u7a0b\u7ea7\u72b6\u6001\u7ba1\u7406&#xff1a;<\/p>\n<p>compile(checkpointer&#061;&#8230;)<br \/>\n        \u2193<br \/>\n\u4fdd\u5b58 Graph State<br \/>\n        \u2193<br \/>\nthread_id \u9694\u79bb\u7ebf\u7a0b<br \/>\n        \u2193<br \/>\n\u540e\u7eed invoke \u81ea\u52a8\u6062\u590d<br \/>\n        \u2193<br \/>\nget_state \u67e5\u770b\u6700\u65b0\u72b6\u6001<br \/>\n        \u2193<br \/>\nget_state_history \u67e5\u770b\u5386\u53f2\u7248\u672c<\/p>\n<p>\u540c\u65f6&#xff0c;\u4e5f\u8981\u7262\u7262\u8bb0\u4f4f\u5b83\u7684\u80fd\u529b\u8fb9\u754c&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\">MemorySaver \u80fd\u8ba9\u65b0\u7f16\u8bd1\u7684 app \u4ece\u540c\u4e00\u4e2a\u5185\u5b58\u540e\u7aef\u6062\u590d\u72b6\u6001&#xff0c;\u4f46\u65e0\u6cd5\u5728 Python \u8fdb\u7a0b\u771f\u6b63\u9000\u51fa\u540e\u4fdd\u7559\u6570\u636e\u3002<\/span><\/p>\n<p>\u56e0\u6b64&#xff0c;\u5b83\u6700\u9002\u5408\u7528\u6765\u5b66\u4e60 Checkpoint \u7684\u5de5\u4f5c\u65b9\u5f0f&#xff0c;\u800c\u4e0d\u662f\u76f4\u63a5\u4f5c\u4e3a\u751f\u4ea7\u6301\u4e45\u5316\u65b9\u6848\u3002<\/p>\n<p>\u4e0b\u4e00\u7bc7\u8fdb\u5165 Redis Persistence&#xff1a;\u628a Checkpoint \u4ece Python \u5185\u5b58\u8fc1\u79fb\u5230\u5916\u90e8\u5b58\u50a8&#xff0c;\u5b9e\u73b0\u771f\u6b63\u7684\u8de8\u8fdb\u7a0b\u6062\u590d&#xff0c;\u5e76\u8fdb\u4e00\u6b65\u8ba8\u8bba\u8fde\u63a5\u5931\u8d25\u65f6\u7684\u964d\u7ea7\u7b56\u7565\u3001\u751f\u4ea7\u914d\u7f6e\u548c\u72b6\u6001\u6cbb\u7406\u3002<\/p>\n<h2 id=\"%E4%B8%80%E9%A1%B5%E9%80%9F%E6%9F%A5\">\u4e00\u9875\u901f\u67e5<\/h2>\n<p>checkpointer &#061; MemorySaver()<\/p>\n<p>app &#061; graph.compile(checkpointer&#061;checkpointer)<\/p>\n<p>config &#061; {<br \/>\n    &#034;configurable&#034;: {<br \/>\n        &#034;thread_id&#034;: &#034;user-id:conversation-id&#034;<br \/>\n    }<br \/>\n}<\/p>\n<p>result &#061; app.invoke(<br \/>\n    {&#034;messages&#034;: [HumanMessage(content&#061;&#034;\u4f60\u597d&#034;)], &#034;turn_count&#034;: 0},<br \/>\n    config&#061;config,<br \/>\n)<\/p>\n<p>latest_state &#061; app.get_state(config)<\/p>\n<p>history &#061; app.get_state_history(config)<\/p>\n<p>MemorySaver        \u2192 \u5f53\u524d\u8fdb\u7a0b\u5185\u4fdd\u5b58<br \/>\nthread_id          \u2192 \u7ebf\u7a0b\u9694\u79bb\u4e0e\u72b6\u6001\u5b9a\u4f4d<br \/>\nget_state          \u2192 \u8bfb\u53d6\u6700\u65b0 StateSnapshot<br \/>\nget_state_history  \u2192 \u67e5\u770b\u5386\u53f2\u7248\u672c\u94fe<br \/>\nReducer            \u2192 \u51b3\u5b9a\u72b6\u6001\u5982\u4f55\u5408\u5e76<br \/>\n\u6301\u4e45\u5316 Checkpointer \u2192 \u5b9e\u73b0\u771f\u6b63\u7684\u8de8\u8fdb\u7a0b\u6062\u590d<\/p>\n<p>\u00a0\u7cfb\u5217\u5bfc\u822a&#xff1a;<span>LangGraph\u4ece\u96f6\u6784\u5efa\u751f\u4ea7\u7ea7 AI Agent \u5e73\u53f0\u7684\u9012\u8fdb\u5f0f\u5b66\u4e60\u9879\u76ee-CSDN\u535a\u5ba2<\/span><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u4e00\u3001\u4e3a\u4ec0\u4e48 Agent \u9700\u8981 Checkpoint&#xff1f;<br \/>\n\u4e8c\u3001\u5148\u5efa\u7acb\u6b63\u786e\u7684\u5fc3\u667a\u6a21\u578b<br \/>\n\u4e09\u3001Checkpoint\u3001Thread \u4e0e\u7248\u672c\u94fe<br \/>\n&#xff08;\u4e00&#xff09;Checkpointer&#xff1a;\u72b6\u6001\u4fdd\u5b58\u540e\u7aef<br \/>\n&#xff08;\u4e8c&#xff09;Thread ID&#xff1a;\u4e00\u6761\u72b6\u6001\u94fe\u7684\u4e1a\u52a1\u6807\u8bc6<br \/>\n&#xff08;\u4e09&#xff09;Checkpoint \u7248\u672c\u94fe&#xff1a;\u72b6\u6001\u4e0d\u53ea\u6709\u201c\u73b0\u5728\u201d<br \/>\n&#xff08;\u56db&#xff09;\u4e00\u6b21 <\/p>\n","protected":false},"author":2,"featured_media":90388,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6401,74,3503,75,50],"topic":[],"class_list":["post-90393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-checkpoint","tag-agent","tag-langgraph","tag-llm","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/90393.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u4e00\u3001\u4e3a\u4ec0\u4e48 Agent \u9700\u8981 Checkpoint&#xff1f; \u4e8c\u3001\u5148\u5efa\u7acb\u6b63\u786e\u7684\u5fc3\u667a\u6a21\u578b \u4e09\u3001Checkpoint\u3001Thread \u4e0e\u7248\u672c\u94fe &#xff08;\u4e00&#xff09;Checkpointer&#xff1a;\u72b6\u6001\u4fdd\u5b58\u540e\u7aef &#xff08;\u4e8c&#xff09;Thread ID&#xff1a;\u4e00\u6761\u72b6\u6001\u94fe\u7684\u4e1a\u52a1\u6807\u8bc6 &#xff08;\u4e09&#xff09;Checkpoint \u7248\u672c\u94fe&#xff1a;\u72b6\u6001\u4e0d\u53ea\u6709\u201c\u73b0\u5728\u201d &#xff08;\u56db&#xff09;\u4e00\u6b21\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/90393.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-05T00:50:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005007-6a7288bf1bd16.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90393.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/90393.html\",\"name\":\"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-05T00:50:12+00:00\",\"dateModified\":\"2026-08-05T00:50:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/90393.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/90393.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90393.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/90393.html","og_locale":"zh_CN","og_type":"article","og_title":"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u4e00\u3001\u4e3a\u4ec0\u4e48 Agent \u9700\u8981 Checkpoint&#xff1f; \u4e8c\u3001\u5148\u5efa\u7acb\u6b63\u786e\u7684\u5fc3\u667a\u6a21\u578b \u4e09\u3001Checkpoint\u3001Thread \u4e0e\u7248\u672c\u94fe &#xff08;\u4e00&#xff09;Checkpointer&#xff1a;\u72b6\u6001\u4fdd\u5b58\u540e\u7aef &#xff08;\u4e8c&#xff09;Thread ID&#xff1a;\u4e00\u6761\u72b6\u6001\u94fe\u7684\u4e1a\u52a1\u6807\u8bc6 &#xff08;\u4e09&#xff09;Checkpoint \u7248\u672c\u94fe&#xff1a;\u72b6\u6001\u4e0d\u53ea\u6709\u201c\u73b0\u5728\u201d &#xff08;\u56db&#xff09;\u4e00\u6b21","og_url":"https:\/\/www.wsisp.com\/helps\/90393.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-05T00:50:12+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260805005007-6a7288bf1bd16.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"12 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/90393.html","url":"https:\/\/www.wsisp.com\/helps\/90393.html","name":"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-05T00:50:12+00:00","dateModified":"2026-08-05T00:50:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/90393.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/90393.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/90393.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"LangGraph Checkpoint \u5165\u95e8\uff1a\u7528 MemorySaver \u4e3a Agent \u88c5\u4e0a\u300c\u53ef\u6062\u590d\u7684\u8bb0\u5fc6\u300d"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=90393"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/90388"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=90393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=90393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=90393"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=90393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}