Fix: timeline ttl expiry - #61
Conversation
|
Hi @DKZed @sshettigar-aerospike @havvari-V0 , could you please take a look at this PR? It fixes the silent timeline record expiry bug when refresh_on_read is enabled in AerospikeSaver. I have also added offline mocked test cases to verify the read-touch behavior. Thanks! |
|
For additional confidence, I also ran an end-to-end verification against a local Aerospike instance with Before patch
After patch
This complements the mocked unit test and confirms that the read-touch policy correctly refreshes the TTL on real Aerospike records. |
DKZed
left a comment
There was a problem hiding this comment.
LGTM
Thanks for finding this. Upon reviewing there are other TTL issues in a similar vein that I will address!
|
Hey @adarshprabhu03, I am really interested in what you're using Aerospike for in the AI space as we are actively increasing our supported frameworks. If you feel like it and are able to share, I would love the feedback and see if we can use it to influence our future work! |
Description
This PR fixes a bug in
AerospikeSaverwhere the__timeline__metadata record would expire and get deleted by Aerospike even if the associated checkpoints were active and refreshed on reads.When
refresh_on_readis enabled, reading a checkpoint viaget_tuple()resets the expiration timer (TTL) for individual checkpoints and the__latest__record, but never touched the__timeline__record. After the default TTL elapsed, the timeline record would expire. This resulted in history lookups (list()) returning empty lists even though active checkpoints still existed in the database.Changes Made
packages/langgraph-checkpoint-aerospike/langgraph/checkpoint/aerospike/saver.py:get_tuple()to retrieve/touch the__timeline__record using the configured read-touch policy (read_touch_ttl_percent: 100) ifself._refresh_on_readis enabled.packages/langgraph-checkpoint-aerospike/tests/test_ttl_behavior.py:test_timeline_refreshes_on_getto verify TTL extension logic against an active Aerospike server.test_timeline_refreshes_on_get_mockedto verify the read-touch behavior offline usingunittest.mock.Testing
test_timeline_refreshes_on_get_mockedto verify thatclient.getis called on the timeline record key with the correct policy{"read_touch_ttl_percent": 100}on retrieval.ruff checkandruff formatto ensure compliance with the repository style.mypyacross the package (passed with no issues).Screenshots (if applicable)
N/A
Additional Notes
This fix ensures that the checkpointer maintains consistency between the active checkpoints and the metadata timeline indexing under sliding TTL policies.