Skip to main content

LangGraph checkpoint saver for SAP HANA Cloud

Project description

langgraph-checkpoint-hana

License: MIT Python 3.10+

LangGraph checkpoint saver for SAP HANA Cloud — persist AI agent state where your enterprise data already lives.

This package implements the LangGraph BaseCheckpointSaver interface for SAP HANA Cloud, enabling conversation memory, human-in-the-loop workflows, time travel, and fault recovery for LangGraph agents running on SAP BTP.

Why HANA?

LangGraph provides official checkpointers for PostgreSQL, SQLite, and Redis. But if your enterprise runs on SAP, your business data is in HANA — and your AI agents should persist their state there too.

Benefits of keeping agent state in HANA Cloud:

  • Co-located with business data — agent state lives alongside financial documents, master data, and transactional records. One database to manage, back up, and secure.
  • Enterprise-grade security — leverage HANA's native audit logging, role-based access control, and encryption at rest.
  • BTP-native deployment — deploy LangGraph agents on SAP BTP (Kyma / Cloud Foundry) with HANA Cloud as the persistence layer. No external database dependencies.
  • Unified querying — join agent decision traces with business data using standard SQL.

Installation

pip install langgraph-checkpoint-hana

Requirements:

  • Python 3.10+
  • SAP HANA Cloud instance (or HANA on-premise 2.0 SPS 05+)
  • hdbcli driver (installed automatically)

Quick Start

from langgraph_checkpoint_hana import HANASaver
from langgraph.graph import StateGraph, MessagesState, START, END

# Create checkpointer from connection parameters
with HANASaver.from_conn_info(
    address="your-instance.hanacloud.ondemand.com",
    port=443,
    user="DBADMIN",
    password="your-password",
) as checkpointer:
    
    # Build your graph
    workflow = StateGraph(MessagesState)
    workflow.add_node("chatbot", chatbot_node)
    workflow.add_edge(START, "chatbot")
    workflow.add_edge("chatbot", END)
    
    # Compile with HANA persistence
    graph = workflow.compile(checkpointer=checkpointer)
    
    # Invoke — state is automatically persisted to HANA
    config = {"configurable": {"thread_id": "user-session-42"}}
    result = graph.invoke(
        {"messages": [("human", "What's our AP aging?")]},
        config,
    )
    
    # State survives restarts — resume anytime
    state = graph.get_state(config)

Usage with Environment Variables

Convenient for containerised deployments on Kyma or Cloud Foundry:

import os
os.environ["HANA_HOST"] = "your-instance.hanacloud.ondemand.com"
os.environ["HANA_PORT"] = "443"
os.environ["HANA_USER"] = "DBADMIN"
os.environ["HANA_PASSWORD"] = "your-password"

checkpointer = HANASaver.from_env()
checkpointer.setup()

Usage with Existing Connection

If you already manage HANA connections in your application (e.g. via a connection pool or SAP CAP service bindings):

from hdbcli import dbapi
from langgraph_checkpoint_hana import HANASaver

conn = dbapi.connect(address="...", port=443, user="...", password="...")
checkpointer = HANASaver(conn=conn)
checkpointer.setup()  # creates tables if needed

# Use with your graph
graph = workflow.compile(checkpointer=checkpointer)

Tables Created

HANASaver.setup() creates two tables (if they don't already exist):

Table Purpose
LANGGRAPH_CHECKPOINTS Stores graph state snapshots (one row per checkpoint)
LANGGRAPH_CHECKPOINT_WRITES Stores pending writes for fault recovery

Both tables use NCLOB columns for serialised data and are keyed by (thread_id, checkpoint_ns, checkpoint_id).

Thread Management

# Delete all state for a thread (cleanup, GDPR, error recovery)
checkpointer.delete_thread("user-session-42")

# List checkpoint history
for cp in checkpointer.list(config, limit=10):
    print(cp.checkpoint["id"], cp.metadata)

# Time travel — get a specific checkpoint
historical_config = {
    "configurable": {
        "thread_id": "user-session-42",
        "checkpoint_id": "1ef4f797-8335-6428-8001-8a1503f9b875",
    }
}
past_state = graph.get_state(historical_config)

Async Support

The hdbcli driver is synchronous. Async methods (aget_tuple, alist, aput, aput_writes, adelete_thread) delegate to their sync counterparts. For high-concurrency async deployments, consider wrapping calls with asyncio.to_thread().

Development

git clone https://github.com/stubborncoder/langgraph-checkpoint-hana.git
cd langgraph-checkpoint-hana
pip install -e ".[dev]"
pytest

Compatibility

Component Tested Versions
LangGraph 0.2.x, 0.3.x
langgraph-checkpoint 2.x
SAP HANA Cloud 2024.x, 2025.x
Python 3.10, 3.11, 3.12

License

MIT

Contributing

Contributions welcome. Please open an issue to discuss before submitting a PR.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langgraph_checkpoint_hana-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langgraph_checkpoint_hana-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_checkpoint_hana-0.1.0.tar.gz.

File metadata

File hashes

Hashes for langgraph_checkpoint_hana-0.1.0.tar.gz
Algorithm Hash digest
SHA256 85b21d37a84ce56ced714843f1d9b93c1d2bb6fe67cb6b238634ac576f2df1eb
MD5 235d2aed6fc70af4320bf1002e44543c
BLAKE2b-256 2b02c8d2be03ae9f53230b0e3c639f02a7a44e6efbf53c0c0a819fa5aedf534d

See more details on using hashes here.

File details

Details for the file langgraph_checkpoint_hana-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_checkpoint_hana-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3a29cf7a079a03d0f54ccafab354d6a55f0778543db8f9dbea3fc9636e7b04c
MD5 e5689fac3a12316b257e4d547c4b48ea
BLAKE2b-256 f91dbee56d4e1ba5b5e956f7057ba6f1771cc0d50998d240e8df2fd04374f0ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page