Repository navigation
Make checkpoint prune --dry-run match the real prune #9777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Wooohaaa
wants to merge
1
commit into
crewAIInc:main
Choose a base branch
from
Wooohaaa:fix/checkpoint-dry-run
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−18
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 LOW: Prune dry run still commits its DELETEs through the connection context manager
TL;DR:
crewai checkpoint prune --dry-runreally deletes rows from the SQLite checkpoint store, including checkpoints from other branches and flows. It runs the same DELETE statements as a real prune and relies on the missingconn.commit()to keep them uncommitted, butwith sqlite3.connect(...)commits the open transaction when the block exits, so the preview persists. Rolling back whendry_runis set keeps the preview read-only.Cause, impact and fix
Cause:
_prune_sqliteexecutes the_DELETE_OLDER_THANand_DELETE_KEEP_Nstatements unconditionally and guards only the explicitconn.commit(). Thewith sqlite3.connect(db_path) as connblock commits any pending transaction on normal exit, so withholding the commit call does not stop the deletes from being written.Impact: An operator running
--dry-runto preview a cleanup permanently loses the oldest checkpoints in that store, not only the rows they meant to drop, and is told those rows only "would" be pruned. The DELETEs carry no branch or flow predicate, so the loss spans every branch sharing the default./.checkpoints.db.Fix: Make the dry-run path explicitly non-destructive: roll back the transaction when
dry_runis true and commit only otherwise, or count the matching rows withSELECT COUNT(*)and skip the DELETEs entirely. Add a test that runs a dry run against a populated store and asserts the row count is unchanged.🔵 `crewai checkpoint prune --dry-run` still deletes SQLite checkpoints: `with sqlite3.connect(...)` commits on exit
🔵
crewai checkpoint prune --dry-runstill deletes SQLite checkpoints:with sqlite3.connect(...)commits on exitSeverity: LOW
TL;DR:
_prune_sqliteinlib/cli/src/crewai_cli/checkpoint_cli.pyonly skipsconn.commit()for--dry-run, but thewith sqlite3.connect(...)block commits the pending DELETEs on exit, so the "preview" deletes them.Impact: Anyone running
crewai checkpoint prune --keep N --dry-runto preview a cleanup silently loses the oldest N checkpoints in that store - including rows belonging to other branches and flows - and is told only how many "would" be removed.Root cause:
conn.commit(), assuming that no commit call means no write, but Python's connection context manager commits any open transaction when thewithblock exits normally.with sqlite3.connect(db_path) as conntherefore persists theDELETEstatements executed at lines 705 and 709 even whendry_runis true; reproduced with the same code shape: 10 rows, dry run reported 7 deleted and 3 rows remained../.checkpoints.db, not just the rows the operator intended to prune.Prompt to fix with AI
React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.