feat(agent-memory): add create_checkpointer() factory with TTL support for LangGraph agents#221
Open
santosh-nallur wants to merge 12 commits into
Open
feat(agent-memory): add create_checkpointer() factory with TTL support for LangGraph agents#221santosh-nallur wants to merge 12 commits into
santosh-nallur wants to merge 12 commits into
Conversation
…gents Adds factory/langgraph_checkpoint.py providing create_checkpointer() which returns LangGraph's InMemorySaver. The factory subpackage is structured to support future framework adapters (store, crewai) without namespace conflicts with the langgraph package itself. Persistent checkpointing backed by the Agent Memory Service is not yet supported. AGENTMAAS-410
Covers return type, ImportError on missing langgraph, and three LangGraph integration tests verifying compile, state persistence, and thread isolation. AGENTMAAS-410
…uide Adds a LangGraph Checkpointer section distinguishing the framework adapter from the core service client. Notes that the current implementation uses InMemorySaver and does not support persistence yet. AGENTMAAS-410
…create_checkpointer State loss on process exit is a relevant operational signal, not a routine info event. Message now names the function and describes the exact limitation. AGENTMAAS-410
Adds TimedInMemorySaver extending InMemorySaver with a daemon background sweep thread that evicts inactive threads based on ttl_seconds. Updates create_checkpointer(ttl_seconds=...) factory to return TimedInMemorySaver when ttl_seconds is provided, or plain InMemorySaver otherwise. TimedInMemorySaver is a temporary home in the SDK factory subpackage. It will migrate to langgraph-checkpoint-sap-agent-memory in Phase 2 — no code change required for consumers of create_checkpointer(). AGENTMAAS-410
…er guide Adds Thread TTL section to the LangGraph Checkpointer documentation covering ttl_seconds usage, TimedInMemorySaver eviction semantics, and the @agent_config decorator pattern for centralised TTL configuration. AGENTMAAS-410
… signature Removes TimedInMemorySaver and its tests. ttl_seconds is retained as a factory parameter for interface stability — TTL will be enforced by HanaAgentMemorySaver when available. InMemorySaver logs a clear warning when ttl_seconds is set explaining the current limitation. AGENTMAAS-410
The centralised TTL configuration via @agent_config is not yet available. Removed from both the factory docstring and the user guide. AGENTMAAS-410
Restores TimedInMemorySaver — InMemorySaver with background daemon sweep for production-grade TTL-based thread eviction. create_checkpointer() returns TimedInMemorySaver when ttl_seconds is set, InMemorySaver otherwise. AGENTMAAS-410
Documents ttl_seconds parameter, TimedInMemorySaver eviction semantics, and the process-exit limitation. Removes the placeholder text that said TTL has no effect. AGENTMAAS-410
Comment on lines
+841
to
+846
| `langgraph` must be installed. The SDK does not declare it as a dependency — | ||
| you control your own LangGraph version. | ||
|
|
||
| ```bash | ||
| pip install langgraph | ||
| ``` |
Member
There was a problem hiding this comment.
langchain is an optional dependency that we are using for the Agent Gateway module. We could follow the same approach here, adding langgraph as an optional dependency and validating and handling it with a proper message if the developer try to use the checkpointer without installing the langgraph dependency. Similar to what we did here:
NicoleMGomes
reviewed
Jul 9, 2026
| - :func:`sap_cloud_sdk.agent_memory.factory.langgraph_checkpoint.create_checkpointer` | ||
| — returns a LangGraph ``BaseCheckpointSaver`` (short-term memory) | ||
| Usage:: |
Contributor
There was a problem hiding this comment.
Suggested change
| Usage:: | |
| Usage: |
NicoleMGomes
reviewed
Jul 9, 2026
| @@ -0,0 +1,117 @@ | |||
| """Unit tests for the create_checkpointer() LangGraph factory.""" | |||
Contributor
There was a problem hiding this comment.
Better to keep same structure as src
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
create_checkpointer()factory in theagent_memorymodule that returns a LangGraphBaseCheckpointSaverappropriate for the current environment. Enables LoB teams (e.g. IBD) to integrate LangGraph agent short-term memory without coupling their agent code to a specific checkpointer implementation.What ships in this PR:
src/sap_cloud_sdk/agent_memory/factory/langgraph_checkpoint.py—create_checkpointer()factory returningInMemorySaver(no TTL) orTimedInMemorySaver(with TTL)src/sap_cloud_sdk/agent_memory/factory/_timed_memory.py—TimedInMemorySaverextendingInMemorySaverwith a daemon background sweep thread for TTL-based thread evictionsrc/sap_cloud_sdk/agent_memory/factory/__init__.py— factory subpackagetests/agent_memory/unit/test_langgraph_checkpointer.py— factory unit teststests/agent_memory/unit/test_timed_memory.py—TimedInMemorySaverunit testssrc/sap_cloud_sdk/agent_memory/user-guide.md— LangGraph Checkpointer sectionusage:
TimedInMemorySaverdesign:_last_activedict updated input()/aput()ttl_secondsof inactivityttl_secondsparameter stable for Phase 2 whenHanaAgentMemorySavershipsType of Change
How to Test
Checklist
Breaking Changes
None. The
factorysubpackage is additive. No existing public API is changed.Additional Notes
TimedInMemorySaveris a temporary home in the SDK factory subpackage. It will migrate tolanggraph-checkpoint-sap-agent-memory(the separate checkpoint library in Phase 2 — no code change required for factory consumers.ttl_secondsparameter is accepted oncreate_checkpointer()regardless of which backend is active, ensuring interface stability for Phase 2.HanaAgentMemorySaverships) will detect the HANA binding at runtime and return it automatically