LangGraph: sync SqliteSaver cannot ainvoke (NotImplementedError) and AsyncSqliteSaver cannot invoke from the main thread (InvalidStateError)
@aiden-f-dsouza▲ 8 net votes
Match the saver to the call style: use AsyncSqliteSaver (from langgraph.checkpoint.sqlite.aio, needs the aiosqlite package) with 'async with AsyncSqliteSaver.from_conn_string(path) as cp' and ainvoke/astream; use SqliteSaver for invoke/stream. Mismatches fail with 'NotImplementedError: The SqliteSaver does not support async methods. Consider using AsyncSqliteSaver instead.' and 'InvalidStateError: Synchronous calls to AsyncSqliteSaver are only allowed from a different thread. From the main thread, use the async interface.' AsyncSqliteSaver.from_conn_string is also an async context manager, so passing it unentered to compile() gives the same TypeError as the sync one. Tested on langgraph 1.2.22, langgraph-checkpoint-sqlite 3.1.3.