Issue with using Annotation.root pattern and checkpoints? #71

Closed
opened 2026-02-15 17:15:23 -05:00 by yindo · 2 comments
Owner

Originally created by @mcgear on GitHub (Aug 27, 2024).

I was upgrading to all the latest langchain and langgraph libraries. In doing so, i noticed that there was a new way to define the State of the graph:

const GraphState = Annotation.Root({
  messages: Annotation<BaseMessage[]>({
    value: (x, y) => x.concat(y),
    default: () => [],
  })
})

I updated the state in one of our tests:
https://github.com/fathym-deno/synaptic/blob/integration/tests/circuits/neurons/EaCChatPromptNeuron.tests.ts

export const LovelaceSourceInformationGraphStateSchema = Annotation.Root({
  Messages: Annotation<BaseMessage[]>({
    reducer: (x, y) => x.concat(y),
    default: () => [],
  }),
});

We have a project that wraps langchain into a configuration based development model, and works to shield the user from keeping up with changes to the API, package versions and so on.

I started getting this error after the upgrade:

error: TypeError: channels[k].fromCheckpoint is not a function
    at emptyChannels (file:///C:/Users/micha_8ygdgy8/AppData/Local/deno/npm/registry.npmjs.org/@langchain/langgraph/0.1.4-rc.1/dist/channels/base.js:32:42)  
    at Function.initialize (file:///C:/Users/micha_8ygdgy8/AppData/Local/deno/npm/registry.npmjs.org/@langchain/langgraph/0.1.4-rc.1/dist/pregel/loop.js:183:26)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async CompiledStateGraph._streamIterator (file:///C:/Users/micha_8ygdgy8/AppData/Local/deno/npm/registry.npmjs.org/@langchain/langgraph/0.1.4-rc.1/dist/pregel/index.js:462:20)
    ```
    
    
Originally created by @mcgear on GitHub (Aug 27, 2024). I was upgrading to all the latest langchain and langgraph libraries. In doing so, i noticed that there was a new way to define the State of the graph: ``` const GraphState = Annotation.Root({ messages: Annotation<BaseMessage[]>({ value: (x, y) => x.concat(y), default: () => [], }) }) ``` I updated the state in one of our tests: https://github.com/fathym-deno/synaptic/blob/integration/tests/circuits/neurons/EaCChatPromptNeuron.tests.ts ``` export const LovelaceSourceInformationGraphStateSchema = Annotation.Root({ Messages: Annotation<BaseMessage[]>({ reducer: (x, y) => x.concat(y), default: () => [], }), }); ``` We have a project that wraps langchain into a configuration based development model, and works to shield the user from keeping up with changes to the API, package versions and so on. I started getting this error after the upgrade: ``` error: TypeError: channels[k].fromCheckpoint is not a function at emptyChannels (file:///C:/Users/micha_8ygdgy8/AppData/Local/deno/npm/registry.npmjs.org/@langchain/langgraph/0.1.4-rc.1/dist/channels/base.js:32:42) at Function.initialize (file:///C:/Users/micha_8ygdgy8/AppData/Local/deno/npm/registry.npmjs.org/@langchain/langgraph/0.1.4-rc.1/dist/pregel/loop.js:183:26) at eventLoopTick (ext:core/01_core.js:168:7) at async CompiledStateGraph._streamIterator (file:///C:/Users/micha_8ygdgy8/AppData/Local/deno/npm/registry.npmjs.org/@langchain/langgraph/0.1.4-rc.1/dist/pregel/index.js:462:20) ```
yindo closed this issue 2026-02-15 17:15:23 -05:00
Author
Owner

@jacoblee93 commented on GitHub (Aug 27, 2024):

Hey @mcgear, sorry you're running into this - yes this looks correct. Can you show me how you're initializing your graph?

@jacoblee93 commented on GitHub (Aug 27, 2024): Hey @mcgear, sorry you're running into this - yes this looks correct. Can you show me how you're initializing your graph?
Author
Owner

@jacoblee93 commented on GitHub (Aug 27, 2024):

If it's this:

            let graph = details.State
              ? new StateGraph({
                channels: details.State as StateGraphArgs<unknown>["channels"],
              })
              : new MessageGraph();

You actually just pass the annotation directly into the constructor like this:

new StateGraph(StateAnnotation)

Please reopen if that doesn't fix it! You can also remain on the old syntax, it isn't going away. It's just a bit more cumbersome.

@jacoblee93 commented on GitHub (Aug 27, 2024): If it's this: ```ts let graph = details.State ? new StateGraph({ channels: details.State as StateGraphArgs<unknown>["channels"], }) : new MessageGraph(); ``` You actually just pass the annotation directly into the constructor like this: ```ts new StateGraph(StateAnnotation) ``` Please reopen if that doesn't fix it! You can also remain on the old syntax, it isn't going away. It's just a bit more cumbersome.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#71