Skip to content

fix: always refresh TTL when refresh_on_read is enabled #95

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

Merged
merged 1 commit into from
Aug 18, 2025

Conversation

bsbodden
Copy link
Contributor

Remove 60% threshold optimization that caused TTL drift between checkpoint keys and user-managed external keys. When refresh_on_read=True, TTL is now always refreshed on checkpoint reads, ensuring predictable behavior for TTL synchronization use cases.

  • Remove threshold logic in both sync and async implementations
  • Simplify TTL refresh behavior to be more intuitive
  • Add comprehensive tests for new TTL behavior
  • Update documentation to be clearer about TTL functionality

Remove 60% threshold optimization to prevent TTL drift between
checkpoint keys and user-managed external keys. When refresh_on_read=True,
TTL is now always refreshed on checkpoint reads, ensuring predictable
behavior for TTL synchronization use cases.

- Remove unnecessary threshold logic in both sync and async implementations
- Simplify TTL refresh behavior to be more intuitive
- Add comprehensive tests for new TTL behavior
- Update documentation to be clearer about TTL functionality
@bsbodden bsbodden requested a review from Copilot August 18, 2025 19:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a TTL synchronization issue in RedisSaver by removing a 60% threshold optimization that caused TTL drift between checkpoint keys and external user-managed keys. The main purpose is to ensure predictable TTL behavior when refresh_on_read=True.

  • Remove 60% TTL threshold logic that only refreshed TTL when it dropped below 60% of the original value
  • Always refresh TTL on checkpoint reads when refresh_on_read=True is enabled
  • Add comprehensive test coverage for the new TTL synchronization behavior

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_ttl_synchronization.py New comprehensive test suite for sync TTL behavior
tests/test_async_ttl_synchronization.py New comprehensive test suite for async TTL behavior
langgraph/checkpoint/redis/aio.py Remove 60% threshold logic in async implementation
langgraph/checkpoint/redis/init.py Remove 60% threshold logic in sync implementation
README.md Update documentation to clarify TTL functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

from langgraph.checkpoint.redis.util import (
to_storage_safe_id,
to_storage_safe_str,
)
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The import statements for checkpoint key generation are repeated in multiple test functions. Consider moving these imports to the top of the file or creating a helper function to reduce code duplication.

Suggested change
)
# Imports moved to top of file

Copilot uses AI. Check for mistakes.

from langgraph.checkpoint.redis.util import (
to_storage_safe_id,
to_storage_safe_str,
)
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The import statements for checkpoint key generation are repeated in multiple test functions. Consider moving these imports to the top of the file or creating a helper function to reduce code duplication.

Suggested change
)

Copilot uses AI. Check for mistakes.

@bsbodden bsbodden merged commit cbc6ef6 into main Aug 18, 2025
20 checks passed
@bsbodden bsbodden deleted the bsb/ttl-revision branch August 18, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant