[FEAT] Add checkpoint for long-running GraphWorkflows#1498
Open
adichaudhary wants to merge 2 commits intokyegomez:masterfrom
Open
[FEAT] Add checkpoint for long-running GraphWorkflows#1498adichaudhary wants to merge 2 commits intokyegomez:masterfrom
adichaudhary wants to merge 2 commits intokyegomez:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds checkpoint-based fault tolerance to GraphWorkflow so long-running, multi-layer executions can resume without re-running completed layers.
Changes:
- Add
checkpoint_dirparameter toGraphWorkflow.__init__and implement per-layer checkpoint save/resume inrun(). - Add
clear_checkpoints(task)helper to remove checkpoint files for a given task. - Add an example script demonstrating checkpointing and a simulated crash/re-run flow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
swarms/structs/graph_workflow.py |
Introduces checkpoint_dir, checkpoint save/resume logic in run(), and clear_checkpoints() cleanup method. |
examples/multi_agent/graphworkflow_examples/graph_workflow_checkpointing.py |
New example showcasing checkpoint usage and a simulated crash scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/multi_agent/graphworkflow_examples/graph_workflow_checkpointing.py
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds checkpoint-based fault tolerance to GraphWorkflow. Long-running pipelines that crash or time out mid-execution previously required a full restart from scratch, re-running every agent and paying for every LLM call again. Now, a checkpoint_dir parameter can be passed at construction time — after each layer completes its outputs are persisted to disk, and on the next run() call with the same task string any already-completed layers are loaded from the checkpoint files and skipped entirely. A clear_checkpoints(task) method is also provided to clean up after a confirmed successful run.
Files Changed
swarms/structs/graph_workflow.py— addedcheckpoint_dirparameter to__init__, checkpoint save/resume logic in the layer execution loop ofrun(), and theclear_checkpoints()methodexamples/multi_agent/graphworkflow_examples/graph_workflow_checkpointing.pyIssue
#1484
Dependencies
No extra dependencies required.
Maintainer
@kyegomez
Twitter
@akc__2025
📚 Documentation preview 📚: https://swarms--1451.org.readthedocs.build/en/1451/