:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(deps): upgrade langgraph-checkpoint to 4.1.1 (#63287)
Chris Volzer615c623f265f
diff --git a/ee/hogai/django_checkpoint/checkpointer.py b/ee/hogai/django_checkpoint/checkpointer.pyindex e1ad04dd2bc1..0277c0f9f62d 100644--- a/ee/hogai/django_checkpoint/checkpointer.py+++ b/ee/hogai/django_checkpoint/checkpointer.py@@ -6,6 +6,7 @@ from typing import Any, Optional, castfrom django.db import transactionfrom django.db.models import Prefetch, Q+import ormsgpackfrom langchain_core.runnables import RunnableConfigfrom langgraph.checkpoint.base import (BaseCheckpointSaver,@@ -16,7 +17,7 @@ from langgraph.checkpoint.base import (PendingWrite,get_checkpoint_id,)-from langgraph.checkpoint.serde.jsonplus import JsonPlusSerializer+from langgraph.checkpoint.serde.jsonplus import JsonPlusSerializer, _msgpack_ext_hook_to_jsonfrom langgraph.checkpoint.serde.types import TASKS, ChannelProtocolfrom posthog.sync import database_sync_to_async@@ -47,9 +48,16 @@ class DjangoCheckpointer(BaseCheckpointSaver[str]):)def _dump_json(self, obj: Any) -> dict[str, Any]:- serialized_metadata = self.jsonplus_serde.dumps(obj)+ # JsonPlusSerializer no longer exposes a JSON mode, so round-trip through msgpack+ # to coerce non-JSON values (e.g. Pydantic models in metadata writes) into+ # JSON-safe structures for the JSONB column.+ type_, blob = self.jsonplus_serde.dumps_typed(obj)+ if type_ != "msgpack":+ raise ValueError(f"Expected msgpack serialization for JSON dump, got {type_}")+ jsonable = ormsgpack.unpackb(blob, ext_hook=_msgpack_ext_hook_to_json, option=ormsgpack.OPT_NON_STR_KEYS)+ serialized = json.dumps(jsonable, ensure_ascii=False)# NOTE: we're using JSON serializer (not msgpack), so we need to remove null characters before writing- nulls_removed = serialized_metadata.decode().replace("\\u0000", "")+ nulls_removed = serialized.replace("\\u0000", "")return json.loads(nulls_removed)def _get_checkpoint_qs(@@ -155,7 +163,7 @@ class DjangoCheckpointer(BaseCheckpointSaver[str]):else {})- # langgraph-checkpoint 2.1 dropped `pending_sends` from the Checkpoint TypedDict, but the langgraph runtime still consumes it via `.get()`, so keep emitting it as an extra key+ # langgraph-checkpoint dropped `pending_sends` from the Checkpoint TypedDict in 2.1, but the langgraph runtime still consumes it via `.get()`, so keep emitting it as an extra keycheckpoint_dict = cast(Checkpoint,{@@ -350,7 +358,7 @@ class DjangoCheckpointer(BaseCheckpointSaver[str]):update_fields=["channel", "type", "blob"],)- # `channel` is typed `None` (deprecated) in the 2.1 base class, but langgraph 0.4 still passes a real channel object, so accept both+ # `channel` is typed `None` (deprecated) in the base class since 2.1, but langgraph 0.4 still passes a real channel object, so accept bothdef get_next_version(self, current: Optional[str | int], channel: Optional[ChannelProtocol] = None) -> str:if current is None:current_v = 0diff --git a/ee/hogai/django_checkpoint/test/test_checkpointer.py b/ee/hogai/django_checkpoint/test/test_checkpointer.pyindex 19d78ba968fd..8cc9d66b066c 100644--- a/ee/hogai/django_checkpoint/test/test_checkpointer.py+++ b/ee/hogai/django_checkpoint/test/test_checkpointer.py@@ -644,11 +644,12 @@ class TestDjangoCheckpointer(NonAtomicBaseTest):]self.assertGreater(len(checkpoints), 0)- # The write side still produces lc markers at this langgraph version+ # langgraph-checkpoint 4.x writes plain JSON: pydantic models in metadata are+ # stored as their kwargs dicts, without lc constructor markersmetadata_by_source = {checkpoint.metadata["source"]: checkpoint.metadata for checkpoint in checkpoints}raw_input_state = metadata_by_source["input"]["writes"]["__start__"]- self.assertEqual(raw_input_state["lc"], 2)- self.assertEqual(raw_input_state["type"], "constructor")+ self.assertNotIn("lc", raw_input_state)+ self.assertEqual(raw_input_state["messages"][0]["content"], "hi")raw_by_id = {str(checkpoint.id): checkpoint for checkpoint in checkpoints}loaded_tuples = [result async for result in saver.alist(config)]diff --git a/pyproject.toml b/pyproject.tomlindex 68870a64b05b..84517c6d434a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -80,7 +80,7 @@ dependencies = ["langchain-openai~=0.3.35","langchain-anthropic~=0.3.22","langgraph==0.4.10",- "langgraph-checkpoint==2.1.2",+ "langgraph-checkpoint==4.1.1","lxml==6.0.2","lzstring==1.0.4","markdown-it-py~=3.0.0",@@ -95,6 +95,7 @@ dependencies = ["openai==1.109.1","openpyxl==3.1.5","orjson==3.11.9",+ "ormsgpack~=1.12","pandas~=2.2.2","paramiko~=3.5.0","pillow==12.2.0",diff --git a/uv.lock b/uv.lockindex 7a700ed7c791..ffd734acf7bd 100644--- a/uv.lock+++ b/uv.lock@@ -3813,15 +3813,15 @@ wheels = [[[package]]name = "langgraph-checkpoint"-version = "2.1.2"+version = "4.1.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "langchain-core" },{ name = "ormsgpack" },]-sdist = { url = "https://files.pythonhosted.org/packages/29/83/6404f6ed23a91d7bc63d7df902d144548434237d017820ceaa8d014035f2/langgraph_checkpoint-2.1.2.tar.gz", hash = "sha256:112e9d067a6eff8937caf198421b1ffba8d9207193f14ac6f89930c1260c06f9", size = 142420, upload-time = "2025-10-07T17:45:17.129Z" }+sdist = { url = "https://files.pythonhosted.org/packages/83/47/886af6f886f0bff2273164a45f008694e48a96ff3cd25ff0228f2aa9480e/langgraph_checkpoint-4.1.1.tar.gz", hash = "sha256:6c2bdb530c91f91d7d9c1bd100925d0fc4f498d418c17f3587d1526279482a25", size = 184020, upload-time = "2026-05-22T16:57:38.503Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/c4/f2/06bf5addf8ee664291e1b9ffa1f28fc9d97e59806dc7de5aea9844cbf335/langgraph_checkpoint-2.1.2-py3-none-any.whl", hash = "sha256:911ebffb069fd01775d4b5184c04aaafc2962fcdf50cf49d524cd4367c4d0c60", size = 45763, upload-time = "2025-10-07T17:45:16.19Z" },+ { url = "https://files.pythonhosted.org/packages/bd/b4/71425e3e38be92611300b9cc5e46a5bf98ab23f5ea8a75b73d02a2f1413c/langgraph_checkpoint-4.1.1-py3-none-any.whl", hash = "sha256:25d29144b082827218e7bc3f1e9b0566a4bb007895cd6cc26f66a8428739f56e", size = 56212, upload-time = "2026-05-22T16:57:37.203Z" },][[package]]@@ -5541,6 +5541,7 @@ dependencies = [{ name = "opentelemetry-instrumentation-requests" },{ name = "opentelemetry-sdk" },{ name = "orjson" },+ { name = "ormsgpack" },{ name = "pandas" },{ name = "paramiko" },{ name = "pillow" },@@ -5782,7 +5783,7 @@ requires-dist = [{ name = "langchain-core", specifier = "~=0.3.81" },{ name = "langchain-openai", specifier = "~=0.3.35" },{ name = "langgraph", specifier = "==0.4.10" },- { name = "langgraph-checkpoint", specifier = "==2.1.2" },+ { name = "langgraph-checkpoint", specifier = "==4.1.1" },{ name = "linkedin-api-client", specifier = "~=0.3.0" },{ name = "lxml", specifier = "==6.0.2" },{ name = "lzstring", specifier = "==1.0.4" },@@ -5810,6 +5811,7 @@ requires-dist = [{ name = "opentelemetry-instrumentation-requests", specifier = "==0.54b1" },{ name = "opentelemetry-sdk", specifier = "==1.33.1" },{ name = "orjson", specifier = "==3.11.9" },+ { name = "ormsgpack", specifier = "~=1.12" },{ name = "pandas", specifier = "~=2.2.2" },{ name = "paramiko", specifier = "~=3.5.0" },{ name = "pillow", specifier = "==12.2.0" },