langchain-ai / langgraph

Build resilient language agents as graphs.
https://langchain-ai.github.io/langgraph/
MIT License
6.74k stars 1.09k forks source link

Compiled graph aget_state() throws exception: 'NoneType' object has no attribute 'pending_writes' #1430

Closed HiraveBapu closed 2 months ago

HiraveBapu commented 2 months ago

Checked other resources

Example Code

compiled_graph = stategraph.compile(checkpointer=checkpointer, interrupt_before=["human_review_node"])

snapshot = await compiled_graph.aget_state(config)

Error Message and Stack Trace (if applicable)

exception: 'NoneType' object has no attribute 'pending_writes'

Description

aget_state throws exception

async def aget_state(self, config: RunnableConfig) -> StateSnapshot:
    """Get the current state of the graph."""
    if not self.checkpointer:
        raise ValueError("No checkpointer set")

    saved = await self.checkpointer.aget_tuple(config)
    checkpoint = saved.checkpoint if saved else empty_checkpoint()

    config = saved.config if saved else config
    async with AsyncChannelsManager(
        self.channels, checkpoint, config, skip_context=True
    ) as (channels, managed):
        next_tasks = prepare_next_tasks(
            checkpoint,
            self.nodes,
            channels,
            managed,
            config,
            saved.metadata.get("step", -1) + 1 if saved else -1,
            for_execution=False,
        )
        return StateSnapshot(
            read_channels(channels, self.stream_channels_asis),
            tuple(t.name for t in next_tasks),
            saved.config if saved else config,
            saved.metadata if saved else None,
            saved.checkpoint["ts"] if saved else None,
            saved.parent_config if saved else None,
            tasks_w_writes(next_tasks, saved.pending_writes), # this line causing issue ?
        )

System Info

python = ">=3.9,<3.13" uvicorn = "^0.30.3" pydantic = {extras = ["email"], version = "^2.7.4"} langchain-community = "^0.2.12" langchain-text-splitters = "^0.2.1" langchain-chroma = "^0.1.3" langchain-google-vertexai = "^1.0.7" distro = "^1.9.0" langchain-openai = "^0.1.22" langchain-aws = "^0.1.17" aiosqlite = "^0.20.0" watchfiles = "^0.22.0" filelock = "^3.15.4" python-multipart = "*" langchain-core = "^0.2.34" sentence-transformers = "^3.0.1" pypdf = "^4.3.1" gunicorn = "^22.0.0" langchain-groq = "^0.1.6" pydantic-settings = "^2.3.4" langchain-mistralai = "^0.1.12" langgraph-checkpoint-sqlite = "^1.0.0" grpcio = "^1.65.4" langgraph = "^0.2.10"

HiraveBapu commented 2 months ago

saved = await self.checkpointer.aget_tuple(config) method is not implemented in langgraph side

vbarda commented 2 months ago

saved = await self.checkpointer.aget_tuple(config) method is not implemented in langgraph side

no, it's implemented on AsyncSqliteSaver, but the bug was still there -- thanks for reporting

vbarda commented 2 months ago

Should be fixed in 0.2.11, let me know if you're still running into issues

HiraveBapu commented 2 months ago

its fixed in 2.11, thank you for prompt reply !