Fixes #8551 `update_state` stores its writes on the checkpoint it addresses. A `DeltaChannel` rebuilds its value by replaying the writes stored on its ancestors, so when that checkpoint already has another child, the edit shows up in that branch too. #8551's repro, editing an earlier turn and then reading the branch that already existed: ``` before the edit: ['in-1', 'first-out', 'in-2', 'second-out'] after the edit: ['in-1', 'first-out', 'patched', 'in-2', 'second-out'] ``` The plain reducer channel in the same graph is unaffected. #8548 already keeps the edited branch itself correct; this is the other direction. ## Fix When `update_state` addresses a checkpoint that is not the thread's latest, the checkpoint it creates snapshots the delta channels the update writes, through the same snapshot #8548 adds for forks, and none of the update's writes are stored on the addressed checkpoint, whatever channels it writes. The edited branch reads the snapshot, and the other branches have nothing new to replay. The addressed checkpoint stays as it was, so a later `as_node=END` update on it doesn't take the edit in, and the edit doesn't show as that checkpoint's task result. On `main` both can happen in any graph, with or without a `DeltaChannel`, and a `DeltaChannel` also takes in the other branch's writes. "Not the latest" is one extra `get_tuple` for the thread, made when the config names a `checkpoint_id`. It compares with the latest put, so a checkpoint that has a child always counts. So does a leaf of an abandoned branch, such as the old head after a fork elsewhere, where nothing could leak; telling the two apart would mean listing the thread, since savers have no lookup by parent. The addressed checkpoint's pending writes can't answer it either: a finished turn that a later run continued from has none, which is #8551's case. Updates on the latest checkpoint are unchanged: no snapshot, same writes. ## Cost Editing an older checkpoint stores one snapshot per delta channel the update writes, the size of that channel's regular snapshot. That includes editing a leaf of an abandoned branch, as above. ## Limits - Threads that already leaked keep the leaked write, since it is stored on the old checkpoint. - The second report in #8551, `RemoveMessage(id=REMOVE_ALL_MESSAGES)` through `_messages_delta_reducer`, is that reducer's documented limit and isn't changed here. ## Tests `test_delta_channel_fork.py`, on the shared checkpointer fixtures: - `update_state` / `aupdate_state` on an older checkpoint, both a finished turn and one whose next node already ran there: the other branch reads back unchanged, and continuing it stays clean - `bulk_update_state` with two supersteps from an older checkpoint - `update_state` with the head's `checkpoint_id` still stores no snapshot - `update_state(None, as_node=END)` on an edited checkpoint: an older one leaves the edit out, also when it wrote only plain channels, and the latest one keeps it in both channels 33 of the 59 cases fail on `main`. The rest pass either way: the head case, the case whose next node already ran, where the saver keeps that node's own write and drops the edit's, and `as_node=END` on the latest checkpoint. Thanks to @AnnaSuSu for the report, the repro, tracing the leak to the writes landing on the addressed checkpoint, and the note that the fix needs a snapshot on the new checkpoint first. --------- Co-authored-by: Wenchao An <64579968+AnnaSuSu@users.noreply.github.com>
Low-level orchestration framework for building stateful agents.
Trusted by companies shaping the future of agents – including Klarna, Replit, Elastic, and more – LangGraph is a low-level orchestration framework for building, managing, and deploying long-running, stateful agents.
pip install -U langgraph
Tip
If you're looking to quickly build agents, check out Deep Agents — a higher-level package built on LangGraph for agents that can plan, use subagents, and leverage file systems for complex tasks.
For an equivalent JS/TS library, check out LangGraph.js and the JS docs.
Why use LangGraph?
LangGraph provides low-level supporting infrastructure for any long-running, stateful workflow or agent:
- Durable execution — Build agents that persist through failures and can run for extended periods, automatically resuming from exactly where they left off.
- Human-in-the-loop — Seamlessly incorporate human oversight by inspecting and modifying agent state at any point during execution.
- Comprehensive memory — Create truly stateful agents with both short-term working memory for ongoing reasoning and long-term persistent memory across sessions.
- Debugging with LangSmith — Gain deep visibility into complex agent behavior with visualization tools that trace execution paths, capture state transitions, and provide detailed runtime metrics.
- Production-ready deployment — Deploy sophisticated agent systems confidently with scalable infrastructure designed to handle the unique challenges of stateful, long-running workflows.
Tip
For developing, debugging, and deploying AI agents and LLM applications, see LangSmith.
LangGraph ecosystem
While LangGraph can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools for building agents.
To improve your LLM application development, pair LangGraph with:
- Deep Agents – Build agents that can plan, use subagents, and leverage file systems for complex tasks.
- LangChain – Provides integrations and composable components to streamline LLM application development.
- LangSmith – Helpful for agent evals and observability. Debug poor-performing LLM app runs, evaluate agent trajectories, gain visibility in production, and improve performance over time.
- LangSmith Deployment – Deploy and scale agents effortlessly with a purpose-built deployment platform for long-running, stateful workflows. Discover, reuse, configure, and share agents across teams – and iterate quickly with visual prototyping in LangSmith Studio.
Documentation
- docs.langchain.com – Comprehensive documentation, including conceptual overviews and guides
- reference.langchain.com/python/langgraph – API reference docs for LangGraph packages
- LangGraph Quickstart – Get started building with LangGraph
- Chat LangChain – Chat with the LangChain documentation and get answers to your questions
Discussions: Visit the LangChain Forum to connect with the community and share all of your technical questions, ideas, and feedback.
Additional resources
- Guides – Quick, actionable code snippets for topics such as streaming, adding memory & persistence, and design patterns (e.g. branching, subgraphs, etc.).
- LangChain Academy – Learn the basics of LangGraph in our free, structured course.
- Case studies – Hear how industry leaders use LangGraph to ship AI applications at scale.
- Contributing Guide – Learn how to contribute to LangChain projects and find good first issues.
- Code of Conduct – Our community guidelines and standards for participation.
Acknowledgements
LangGraph is inspired by Pregel and Apache Beam. The public interface draws inspiration from NetworkX. LangGraph is built by LangChain Inc, the creators of LangChain, but can be used without LangChain.