-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
bugSomething isn't workingSomething isn't workingpendingawaiting review/confirmation by maintainerawaiting review/confirmation by maintainer
Description
Checked other resources
- This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
- I added a clear and detailed title that summarizes the issue.
- I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
- I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.
Example Code
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["langgraph>=1.0.2", "langgraph-checkpoint>=2.1.1"]
# ///
"""
Minimal reproduction of LangGraph InMemorySaver bug.
"""
import asyncio
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, START, MessagesState, StateGraph
def node(state):
return state
async def main():
checkpointer = InMemorySaver()
async with checkpointer as entered:
graph = StateGraph(MessagesState)
graph.add_node("node", node)
graph.add_edge(START, "node")
graph.add_edge("node", END)
app = graph.compile(checkpointer=entered)
try:
async for chunk in app.astream(
{"messages": [("user", "test")]},
config={"configurable": {"thread_id": "1"}},
):
print(f"Chunk: {chunk}")
except AttributeError as e:
print(f"ERROR: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(main())Error Message and Stack Trace (if applicable)
ERROR: 'ExitStack' object has no attribute 'get_next_version'Description
When streaming a graph using InMemorySaver, we are seeing AttributeError: 'ExitStack' object has no attribute 'get_next_version' exception.
Using this patched version of the InMemorySaver seems to resolve the issue:
class PatchedInMemorySaver(InMemorySaver):
@override
async def __aenter__(self) -> InMemorySaver:
await super().__aenter__()
return self
@override
def __enter__(self) -> InMemorySaver:
super().__enter__()
return selfSystem Info
System Information
------------------
> OS: Darwin
> OS Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:21 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6000
> Python Version: 3.12.6 (main, Sep 12 2024, 11:45:16) [Clang 14.0.0 (clang-1400.0.29.202)]
Package Information
-------------------
> langchain_core: 1.0.2
> langchain: 1.0.3
> langchain_community: 0.4.1
> langsmith: 0.4.38
> langchain_anthropic: 1.0.1
> langchain_classic: 1.0.0
> langchain_glean: 0.3.3
> langchain_mcp_adapters: 0.1.12
> langchain_openai: 1.0.1
> langchain_qdrant: 1.0.0
> langchain_text_splitters: 1.0.0
> langgraph_sdk: 0.2.3
Optional packages not installed
-------------------------------
> langserve
Other Dependencies
------------------
> aiohttp: 3.12.14
> anthropic: 0.69.0
> async-timeout: Installed. No version info available.
> claude-agent-sdk: 0.1.5
> codespell: Installed. No version info available.
> commitizen: Installed. No version info available.
> dataclasses-json: 0.6.7
> fastembed: Installed. No version info available.
> glean-api-client: 0.6.6
> httpx: 0.28.1
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> langchain-aws: Installed. No version info available.
> langchain-deepseek: Installed. No version info available.
> langchain-fireworks: Installed. No version info available.
> langchain-google-genai: Installed. No version info available.
> langchain-google-vertexai: Installed. No version info available.
> langchain-groq: Installed. No version info available.
> langchain-huggingface: Installed. No version info available.
> langchain-mistralai: Installed. No version info available.
> langchain-ollama: Installed. No version info available.
> langchain-perplexity: Installed. No version info available.
> langchain-tests: Installed. No version info available.
> langchain-together: Installed. No version info available.
> langchain-xai: Installed. No version info available.
> langgraph: 1.0.2
> langsmith-pyo3: Installed. No version info available.
> mcp: 1.17.0
> mypy: Installed. No version info available.
> numpy: 2.2.6
> openai: 2.5.0
> openai-agents: Installed. No version info available.
> opentelemetry-api: 1.30.0
> opentelemetry-exporter-otlp-proto-http: 1.30.0
> opentelemetry-sdk: 1.30.0
> orjson: 3.11.3
> packaging: 25.0
> pydantic: 2.12.3
> pydantic-settings: 2.11.0
> pytest: 9.0.1
> pytest-asyncio: 1.3.0
> pytest-socket: Installed. No version info available.
> pytest-watcher: Installed. No version info available.
> python-dotenv: 1.1.1
> pyyaml: 6.0.2
> PyYAML: 6.0.2
> qdrant-client: 1.14.3
> requests: 2.32.5
> requests-toolbelt: 1.0.0
> rich: 14.0.0
> ruff: 0.14.0
> sqlalchemy: 2.0.41
> SQLAlchemy: 2.0.41
> tenacity: 9.1.2
> tiktoken: 0.9.0
> types-requests: 2.32.4.20250913
> typing-extensions: 4.15.0
> vcrpy: 7.0.0
> zstandard: 0.23.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpendingawaiting review/confirmation by maintainerawaiting review/confirmation by maintainer