Error when loading from checkpoint #156

Open
opened 2026-02-15 17:16:31 -05:00 by yindo · 1 comment
Owner

Originally created by @fserafini-DQ on GitHub (Jan 12, 2025).

Hello, I have the error below when I try to retrieve the state from a postgres (or sqlite) checkpoint saver.

I debugged a bit and what I have found is that in the file node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js the loader import { load } from "@langchain/core/load"; only load the importMap for the namespace "langchain_core" and not for the namespace "langchain", which is required by the object produced by the ChatOpenAI constructor. If I change the loader to import { load } from "langchain/load";, it works.

This is an extract of the code that produce the error:

import { ChatOpenAI } from "@langchain/openai";
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";

async function createGraph() {
  const graph = new StateGraph(GraphState)
  ...

  const checkpointer = PostgresSaver.fromConnString("postgresql://dev:dev@localhost:5432/dev");
  await checkpointer.setup();
  const app = graph.compile({ checkpointer });
  return app;
}

async function main(query: string) {
  const app = await createGraph();

  const llm = new ChatOpenAI({
    modelName: "gpt-4o",
    temperature: 0,
  }).bindTools(tools);

  const config = {
    configurable: { thread_id: "1" },
    streamMode: "values" as const,
  };

  const stream = await app.stream({
    query,
    llm,
  }, config);

  for await (const event of stream) {
  ...
  }
}

const query = "...";
main(query);

The error:

node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

Error: Invalid namespace: $ -> {"lc":1,"type":"constructor","id":["langchain","chat_models","openai","ChatOpenAI"],"kwargs":{"model":"gpt-4o","temperature":0,"openai_api_key":{"lc":1,"type":"secret","id":["OPENAI_API_KEY"]}}}
    at Object.reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/core/dist/load/index.js:117:19)
    at load (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/core/dist/load/index.js:161:20)
    at _reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js:67:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js:28:33)
    at async _reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js:28:33)
    at async file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:114:13
    at async Promise.all (index 0)
    at async PostgresSaver._loadBlobs (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:110:25)
    at async PostgresSaver._loadCheckpoint (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:103:29)

Node.js v20.18.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Thanks in advance!

Originally created by @fserafini-DQ on GitHub (Jan 12, 2025). Hello, I have the error below when I try to retrieve the state from a postgres (or sqlite) checkpoint saver. I debugged a bit and what I have found is that in the file `node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js` the loader `import { load } from "@langchain/core/load";` only load the importMap for the namespace "langchain_core" and not for the namespace "langchain", which is required by the object produced by the ChatOpenAI constructor. If I change the loader to `import { load } from "langchain/load";`, it works. This is an extract of the code that produce the error: ``` import { ChatOpenAI } from "@langchain/openai"; import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres"; async function createGraph() { const graph = new StateGraph(GraphState) ... const checkpointer = PostgresSaver.fromConnString("postgresql://dev:dev@localhost:5432/dev"); await checkpointer.setup(); const app = graph.compile({ checkpointer }); return app; } async function main(query: string) { const app = await createGraph(); const llm = new ChatOpenAI({ modelName: "gpt-4o", temperature: 0, }).bindTools(tools); const config = { configurable: { thread_id: "1" }, streamMode: "values" as const, }; const stream = await app.stream({ query, llm, }, config); for await (const event of stream) { ... } } const query = "..."; main(query); ``` The error: ``` node:internal/process/promises:391 triggerUncaughtException(err, true /* fromPromise */); ^ Error: Invalid namespace: $ -> {"lc":1,"type":"constructor","id":["langchain","chat_models","openai","ChatOpenAI"],"kwargs":{"model":"gpt-4o","temperature":0,"openai_api_key":{"lc":1,"type":"secret","id":["OPENAI_API_KEY"]}}} at Object.reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/core/dist/load/index.js:117:19) at load (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/core/dist/load/index.js:161:20) at _reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js:67:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async _reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js:28:33) at async _reviver (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js:28:33) at async file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:114:13 at async Promise.all (index 0) at async PostgresSaver._loadBlobs (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:110:25) at async PostgresSaver._loadCheckpoint (file:///Users/federico/Workspace/langtool-template/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:103:29) Node.js v20.18.1 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` Thanks in advance!
yindo added the bug label 2026-02-15 17:16:31 -05:00
Author
Owner

@fkmurphy commented on GitHub (Jul 25, 2025):

some solution? i received "Invalid identifier $" when use ChatMessage class in graph state

@fkmurphy commented on GitHub (Jul 25, 2025): some solution? i received "Invalid identifier $" when use `ChatMessage` class in graph state
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#156