Skip to content

Handle missing config keys during checkpoint search #10

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 6 commits into from
Mar 6, 2025

Conversation

abrookins
Copy link
Contributor

@abrookins abrookins commented Feb 27, 2025

When queried for checkpoints of a root graph, the config object the checkpointer receives may get checkpoint_id or checkpoint_ns keys with None or empty string values, or these keys may be missing. Our queries are not handling this situation well.

With an empty checkpoint_id, we end up querying for the literal None string:

1740785440.033103 [0 192.168.65.1:40503] "FT.SEARCH" "checkpoints" "((@thread_id:{book_flight_test} @checkpoint_ns:{respond\\:6b5253e5\\-407b\\-cf32\\-679b\\-cd3fa05fc42f}) @checkpoint_id:{None})" "RETURN" "6" "thread_id" "checkpoint_ns" "checkpoint_id" "parent_checkpoint_id" "$.checkpoint" "$.metadata" "SORTBY" "checkpoint_id" "DESC" "DIALECT" "2" "LIMIT" "0" "1"

This doesn't find anything, so the checkpointer fails to return conversation history, and memory "doesn't work."

On the other hand, if checkpoint_ns, is unset, we don't include it in the query. This conflicts with the Postgres and SQLlite checkpointer implementations, which search for a literal empty string in that case. The difference is that performing an exact match on only checkpoints whose checkpoint_ns is empty finds a different set of checkpoints than "find any matching checkpoint with or without a checkpoint_ns".

Our index doesn't support querying for empty strings on these fields (we would need the INDEXEMPTY option on fields, which RedisVL doesn't currently support and only recent versions of RediSearch support).

This commit doesn't entirely solve the problem, however. Now, we are searching for any checkpoint for the thread, not checkpoints with an empty checkpoint_id or checkpoint_ns. We need to store a sentinel value like "empty" and then query for it when the keys are not present in config.

When queried for checkpoints of a root graph, the `config` object the
checkpointer receives will not have a `checkpoint_id` or `checkpoint_ns`
key. Currently, we reinterpret their absence as presence but with either
an empty string or the string "None", neither of which will find
anything when queried. One because we aren't saving the string "None,"
and the other because this index doesn't support querying for empty
strings on these fields (would need the INDEXEMPTY option on fields,
which RedisVL doesn't currently support and only recent versions of
RediSearch support).

This commit doesn't entirely solve the problem, however. Now, we are
searching for any checkpoint for the thread, not checkpoints for the
thread for the root graph. We need to store a sentinel value like
"__empty__" and then query for it when the keys are not present in
config.
@tylerhutcherson
Copy link
Contributor

When queried for checkpoints of a root graph, the config object the checkpointer receives will not have a checkpoint_id or checkpoint_ns key. Currently, we reinterpret their absence as presence but with either an empty string or the string "None", neither of which will find anything when queried. One because we aren't saving the string "None," and the other because this index doesn't support querying for empty strings on these fields (would need the INDEXEMPTY option on fields, which RedisVL doesn't currently support and only recent versions of RediSearch support).

This commit doesn't entirely solve the problem, however. Now, we are searching for any checkpoint for the thread, not checkpoints for the thread for the root graph. We need to store a sentinel value like "empty" and then query for it when the keys are not present in config.

Good catch/fix. @abrookins let's create the ticket to address redisvl gaps in the field definitions for INDEXEMPTY. Assuming Redis throws some kind of error when applied in a non-supported version of Redis, I would be in favor of adding support in RedisVL and let the failure flow through. This is exactly the kind of scope for 0.5.0 we should address :)

Copy link
Contributor

@tylerhutcherson tylerhutcherson left a comment

Choose a reason for hiding this comment

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

Looks great -- thanks!

@abrookins abrookins merged commit d9c566a into main Mar 6, 2025
19 checks passed
@tylerhutcherson tylerhutcherson deleted the fix/RAAE-691-missing-config-keys branch March 6, 2025 13:28
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.

2 participants