Skip to content

Conversation

@bsbodden
Copy link
Contributor

@bsbodden bsbodden commented Oct 7, 2025

…lues

The make_write_keys_zset_key method was not converting empty checkpoint_ns values to the "empty" sentinel, causing a mismatch between keys created during put_writes and keys searched during delete_thread.

This resulted in write_keys_zset sorted sets not being cleaned up when delete_thread was called, leaving orphaned keys in Redis.

Changes:

  • Update make_write_keys_zset_key to use to_storage_safe_id and to_storage_safe_str for consistent key generation
  • Fix key registry initialization to properly initialize after Redis client configuration in setup() method
  • Add comprehensive integration tests covering sync/async deletion scenarios with empty and non-empty checkpoint namespaces

Fixes #104

…lues (#104)

The make_write_keys_zset_key method was not converting empty checkpoint_ns
values to the "__empty__" sentinel, causing a mismatch between keys created
during put_writes and keys searched during delete_thread.

This resulted in write_keys_zset sorted sets not being cleaned up when
delete_thread was called, leaving orphaned keys in Redis.

Changes:
- Update make_write_keys_zset_key to use to_storage_safe_id and
  to_storage_safe_str for consistent key generation
- Fix key registry initialization to properly initialize after Redis
  client configuration in setup() method
- Add comprehensive integration tests covering sync/async deletion
  scenarios with empty and non-empty checkpoint namespaces

Fixes #104
Copy link

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 bug where the write_keys_zset sorted sets were not being properly cleaned up during thread deletion due to inconsistent key generation between the put_writes and delete_thread operations, specifically when handling empty checkpoint namespace values.

  • Updates the make_write_keys_zset_key method to use storage-safe conversion functions for consistent key generation
  • Fixes initialization order of the key registry to ensure proper Redis client configuration
  • Adds comprehensive integration tests covering sync/async deletion scenarios with various checkpoint namespace configurations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/test_issue_104_delete_write_keys_zset.py New comprehensive test suite verifying write_keys_zset cleanup during thread deletion
langgraph/checkpoint/redis/key_registry.py Updated make_write_keys_zset_key method to use storage-safe conversion functions
langgraph/checkpoint/redis/init.py Fixed key registry initialization order in RedisSaver constructor

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

@bsbodden bsbodden merged commit 79a4932 into main Oct 8, 2025
19 checks passed
@bsbodden bsbodden deleted the bsb/issue-104 branch October 8, 2025 00:43
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.

make_write_keys_zset_key doesnt check empty input

2 participants