@@ -66,6 +66,12 @@ plain text, and the service makes it searchable by meaning.
6666 - [ Mounted Secrets (Kubernetes)] ( #mounted-secrets-kubernetes )
6767 - [ Environment Variables] ( #environment-variables )
6868 - [ UAA JSON Schema] ( #uaa-json-schema )
69+ - [ LangGraph Checkpointer] ( #langgraph-checkpointer )
70+ - [ Prerequisites] ( #prerequisites )
71+ - [ Import] ( #import-1 )
72+ - [ Usage with LangGraph StateGraph] ( #usage-with-langgraph-stategraph )
73+ - [ Usage with LangChain create\_ agent] ( #usage-with-langchain-create_agent )
74+ - [ Thread TTL] ( #thread-ttl )
6975
7076## Installation
7177
@@ -898,3 +904,116 @@ The `uaa` key must contain a JSON string with the XSUAA credentials:
898904 " url" : " https://subdomain.authentication.region.hana.ondemand.com"
899905}
900906```
907+
908+ # # LangGraph Checkpointer
909+
910+ > This section covers the LangGraph- specific
911+ > factory for short- term memory (checkpointing). It is only relevant if your agent
912+ > is built with LangGraph or LangChain' s `create_agent()`. The core
913+ > `AgentMemoryClient` and `create_client()` above are framework- agnostic and work
914+ > independently of this section.
915+
916+ For LangGraph agents, the `agent_memory` module provides a `create_checkpointer()`
917+ factory in the `factory` subpackage. It returns a `BaseCheckpointSaver` that
918+ manages short- term session memory — conversation state, thread continuity, and
919+ HITL support — natively within LangGraph.
920+
921+ > [! NOTE ]
922+ > The current implementation uses LangGraph' s `InMemorySaver` or
923+ > `TimedInMemorySaver` (when `ttl_seconds` is set ). State is held in - process
924+ > and does not survive restarts. Persistent checkpointing backed by the
925+ > Agent Memory Service is not yet supported.
926+
927+ # ## Prerequisites
928+
929+ `langgraph` is an optional dependency. Install it via the SDK extra or directly:
930+
931+ ```bash
932+ # Via SDK optional extra (recommended)
933+ pip install " sap-cloud-sdk[langgraph]"
934+
935+ # Or install langgraph directly
936+ pip install langgraph
937+ ```
938+
939+ # ## Import
940+
941+ ```python
942+ from sap_cloud_sdk.agent_memory.factory.langgraph_checkpoint import create_checkpointer
943+ ```
944+
945+ # ## Usage with LangGraph StateGraph
946+
947+ ```python
948+ from sap_cloud_sdk.agent_memory.factory.langgraph_checkpoint import create_checkpointer
949+
950+ checkpointer = create_checkpointer()
951+ app = workflow.compile(checkpointer = checkpointer)
952+
953+ result = app.invoke(
954+ {" messages" : [{" role" : " user" , " content" : " hello" }]},
955+ {" configurable" : {" thread_id" : " session-1" }},
956+ )
957+ ```
958+
959+ # ## Usage with LangChain create_agent
960+
961+ ```python
962+ from langchain.agents import create_agent
963+ from sap_cloud_sdk.agent_memory.factory.langgraph_checkpoint import create_checkpointer
964+
965+ agent = create_agent(
966+ model = " ..." ,
967+ tools = [... ],
968+ checkpointer = create_checkpointer(),
969+ )
970+ ```
971+
972+ # ## Thread TTL
973+
974+ Pass `ttl_seconds` to evict threads that have been inactive for the given
975+ period. This prevents unbounded memory growth in long - running processes.
976+
977+ ```python
978+ # Evict threads inactive for more than 1 hour
979+ checkpointer = create_checkpointer(ttl_seconds = 3600 )
980+ ```
981+
982+ When `ttl_seconds` is set , the factory returns a `TimedInMemorySaver` that
983+ tracks last- active time per thread and evicts inactive threads via a
984+ background daemon sweep. Eviction is best- effort — a thread may live up to
985+ `ttl_seconds + 60 ` seconds before deletion.
986+
987+ # ### Exposing TTL as a configurable parameter with `@agent_config`
988+
989+ Use `@ agent_config` from `sap_cloud_sdk.agent_decorators` to expose
990+ `ttl_seconds` as an operator- adjustable configuration field. The key
991+ `config.checkpointer.ttl_seconds` groups it with other checkpointer settings
992+ so external tooling can surface it in the low- code UI alongside model
993+ selection and temperature.
994+
995+ ```python
996+ from sap_cloud_sdk.agent_decorators import agent_config
997+ from sap_cloud_sdk.agent_memory.factory.langgraph_checkpoint import create_checkpointer
998+
999+
1000+ @ agent_config(
1001+ key = " config.checkpointer.ttl_seconds" ,
1002+ label = " Thread TTL (seconds)" ,
1003+ description = " Evict inactive conversation threads after this period of "
1004+ " inactivity. Set to 0 to disable eviction." ,
1005+ )
1006+ def thread_ttl_seconds() -> int :
1007+ return 3600 # 1 hour
1008+
1009+
1010+ class MyAgent:
1011+ def __init__ (self ):
1012+ ttl = thread_ttl_seconds()
1013+ self ._checkpointer = create_checkpointer(ttl_seconds = ttl or None )
1014+ ```
1015+
1016+ > [! NOTE ]
1017+ > `TimedInMemorySaver` state does not survive process restarts — the TTL
1018+ > applies to in - process memory only. Persistent TTL enforcement will be
1019+ > available when the Agent Memory Service checkpointer ships.
0 commit comments