Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the graph includes an async BaseCheckpointSaver and uses get_state_history, the program hangs #2992

Open
4 tasks done
gbaian10 opened this issue Jan 10, 2025 · 0 comments

Comments

@gbaian10
Copy link
Contributor

gbaian10 commented Jan 10, 2025

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • 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

import asyncio

from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
from langgraph.graph import END, START, MessagesState, StateGraph


async def main() -> None:
    builder = StateGraph(MessagesState)
    builder.add_node("foo", lambda _: None)
    builder.add_edge(START, "foo")
    builder.add_edge("foo", END)

    async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer:
        graph = builder.compile(checkpointer=checkpointer)
        config = {"configurable": {"thread_id": "1"}}
        await graph.ainvoke({"messages": []}, config)
        for state in graph.get_state_history(config):
            print(state)

        # async for state in graph.aget_state_history(config):
        #     print(state)


if __name__ == "__main__":
    asyncio.run(main())

Description

When using a graph with async checkpointer(sqlite / postgres) and calling sync method get_state_history, the program blocks and cannot continue running.

I expect the sync method to either throw a NotImplementedError exception or continue running, but without leveraging the benefits of async.

System Info

System Information

OS: Linux
Python Version: 3.13.1 (main, Dec 4 2024, 08:54:15) [GCC 13.2.0]

Package Information

langchain_core: 0.3.29
langgraph: 0.2.62
langgraph-checkpoint-sqlite: 2.0.1
langgraph-checkpoint-postgres: 2.0.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant