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

Closed
4 tasks done
gbaian10 opened this issue Jan 10, 2025 · 7 comments
Closed
4 tasks done

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

@vbarda
Copy link
Collaborator

vbarda commented Jan 14, 2025

Thanks for flagging - fixed here #3019

@gbaian10
Copy link
Contributor Author

I haven't tried checkpoint-duckdb, but I guess it might have the same issue?

@vbarda
Copy link
Collaborator

vbarda commented Jan 14, 2025

Good call -- will update that one as well. In the meantime, Sqlite/Postgres are released, so closing the issue

@vbarda vbarda closed this as completed Jan 14, 2025
@gbaian10
Copy link
Contributor Author

Thank you 😊

@hnykda
Copy link

hnykda commented Jan 19, 2025

Huh, I am getting the same with async postgres... this hangs, all on latest versions.

Image

This works, however:

async for state in agent.checkpointer.alist(config):
    print(state)

Interestingly, after I do this, it kinda kills the whole checkpointer - getting state also hangs, even though it works before calling this (same for that alist).

@vbarda
Copy link
Collaborator

vbarda commented Jan 20, 2025

hm, I would double-check in fresh virtual environment with the latest versions -- the above code is supposed to raise an error

@hnykda
Copy link

hnykda commented Jan 20, 2025

And it did not raise anything? Feel free to ignore me, might be me...

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

3 participants