-
Notifications
You must be signed in to change notification settings - Fork 51
fix: make Redis checkpoint listing conformant #186
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,34 @@ | |
| REDIS_KEY_SEPARATOR = ":" | ||
| CHECKPOINT_PREFIX = "checkpoint" | ||
| CHECKPOINT_WRITE_PREFIX = "checkpoint_write" | ||
| INDEXED_CHECKPOINT_FILTER_KEYS = {"source", "step", "thread_id", "run_id"} | ||
|
|
||
|
|
||
| def _metadata_filter_matches( | ||
| metadata: dict[str, Any], filters: Optional[dict[str, Any]] | ||
| ) -> bool: | ||
| """Return whether checkpoint metadata matches user-supplied filters.""" | ||
| if not filters: | ||
| return True | ||
| for key, expected in filters.items(): | ||
| if key == "thread_id": | ||
| continue | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| actual = metadata.get(key) | ||
| if isinstance(expected, list): | ||
| if actual not in expected: | ||
| return False | ||
| elif actual != expected: | ||
| return False | ||
| return True | ||
|
|
||
|
|
||
| def _checkpoint_id_filter_matches( | ||
| checkpoint_id: str, before_checkpoint_id: Optional[str] | ||
| ) -> bool: | ||
| """Apply list(before=...) using the same descending checkpoint_id order.""" | ||
| if not before_checkpoint_id: | ||
| return True | ||
| return checkpoint_id < before_checkpoint_id | ||
|
|
||
|
|
||
| class BaseRedisSaver(BaseCheckpointSaver[str], Generic[RedisClientType, IndexType]): | ||
|
|
||
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.
In post-filter mode the search always fetches only the first 10,000 docs, then applies metadata/
beforefiltering in Python. If matching checkpoints are beyond that initial window (or the caller requestslimit > 10000), they can never be returned even though they exist, so results become silently incomplete. This affects pagination/filter correctness whenever histories are larger than 10k entries.Useful? React with 👍 / 👎.