- 运行图,使用 LangGraph SDK 的 client.runs.wait 或 client.runs.stream API 进行初始输入。
- 识别现有线程中的检查点:使用 client.threads.get_history 方法检索特定
thread_id的执行历史记录并找到所需的checkpoint_id。 或者,在您希望执行暂停的节点之前设置断点。然后,您可以找到记录到该断点的最新检查点。 - (可选)修改图状态:使用 client.threads.update_state 方法修改检查点处的图状态并从替代状态恢复执行。
- 从检查点恢复执行:使用 client.runs.wait 或 client.runs.stream API,输入为
None以及适当的thread_id和checkpoint_id。
在工作流程中使用时间旅行
Example graph
Example graph
1. 运行图
- Python
- JavaScript
- cURL
2. Identify a checkpoint
- Python
- JavaScript
- cURL
3. Update the state
update_state will create a new checkpoint. The new checkpoint will be associated with the same thread, but a new checkpoint ID.
- Python
- JavaScript
- cURL
4. Resume execution from the checkpoint
- Python
- JavaScript
- cURL
Learn more
- LangGraph time travel guide: learn more about using time travel in LangGraph.