gettinf issue with node state graph workflows #170

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

Originally created by @sahil2832005 on GitHub (Feb 13, 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

const { StateGraph } = require("@langchain/langgraph");
// const { MemorySaver } = require("@langchain/langgraph");
const { createAgent, llm, memory } = require("../langchainConfig");
const { BaseChannel } = require("@langchain/langgraph/pregel"); // Correct import path

// const memorySaver = new MemorySaver();

const graph = new StateGraph({
  channels: {
      chat_history: {
          value: [],
          aggregate: "append" // Use built-in aggregation
      },
      deployment_status: { value: "pending" },
      ai_response: { value: "" },
      user_message: { value: "" },
      user: { value: null }
  },
  // memory: new MemorySaver()
});


// ===== NODES ===== //
graph.addNode("processInputWithLLM", async (state) => {
    console.log("\n=== LLM Processing ===");
    const agent = await createAgent(llm, memory);
    const result = await agent.invoke({ input: state.user_message });
    return { ai_response: result.output };
});

graph.addNode("checkPermissions", async (state) => {
    console.log("\n=== Checking Permissions ===");
    if (!state.user?.hasDeploymentAccess) {
        throw new Error("User lacks deployment permissions");
    }
    return { deployment_status: "approved" };
});

graph.addNode("triggerDeployment", async (state) => {
    console.log("\n=== Triggering Deployment ===");
    console.log("Received state:", JSON.stringify(state, null, 2));
    // Add actual deployment logic here
    return { deployment_status: "in_progress" };
});

graph.addNode("validateDeployment", async (state) => {
    console.log("\n=== Validating Deployment ===");
    const success = Math.random() > 0.2; // Replace with real validation
    return { deployment_status: success ? "successful" : "failed" };
});

graph.addNode("logConversation", async (state) => {
    console.log("\n=== Logging Conversation ===");
    return {
        chat_history: [
            ...state.chat_history,
            `User: ${state.user_message}`,
            `AI: ${state.ai_response}`,
            `Status: ${state.deployment_status}`
        ]
    };
});

// ===== EDGES ===== //
graph.addEdge("processInputWithLLM", "checkPermissions");
graph.addEdge("checkPermissions", "triggerDeployment");
graph.addEdge("triggerDeployment", "validateDeployment");
graph.addEdge("validateDeployment", "logConversation");

// ===== GRAPH CONFIG ===== //
graph.setEntryPoint("processInputWithLLM");
graph.setFinishPoint("logConversation"); // Explicit finish point

const workflow = graph.compile();

// ===== EXECUTION HANDLER ===== //
const runDeploymentWorkflow = async (user, userMessage) => {
    const initialState = {
        chat_history: [],
        deployment_status: "pending",
        ai_response: "",
        user_message: userMessage,
        user: user
    };

    try {
        console.log("\n=== Starting Workflow ===");
        const result = await workflow.invoke(initialState);
        console.log("\n=== Final State ===");
        console.log(JSON.stringify(result, null, 2));
        return result;
    } catch (error) {
        console.error("Workflow Failed:", error);
        throw new Error(`Deployment failed: ${error.message}`);
    }
};

module.exports = { runDeploymentWorkflow };

Error Message and Stack Trace (if applicable)

Workflow Failed: TypeError: this.operator is not a function
    at BinaryOperatorAggregate.update (D:\Node  js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\channels\binop.cjs:57:35)
    at _applyWrites (D:\Node  js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\algo.cjs:205:46)
    at PregelLoop.tick (D:\Node  js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\loop.cjs:454:67)
    at CompiledStateGraph._runLoop (D:\Node  js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\index.cjs:1010:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async createAndRunLoop (D:\Node  js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\index.cjs:908:17)
web hook Worker is ready to process jobs.
deployment Worker is ready to process jobs.
Failed queue worker is ready to process jobs.

Description

i am trying to use langgraph state graph and it not completes my all node breaks by giving me this response and above mentioned stack strace this.operator is not a function guide me to fix it

System Info

"dependencies": {
"@aws-sdk/client-ecs": "^3.693.0",
"@clickhouse/client": "^1.8.1",
"@langchain/community": "^0.3.29",
"@langchain/core": "^0.3.39",
"@langchain/groq": "^0.1.3",
"@langchain/langgraph": "^0.2.46",
"@langchain/openai": "^0.4.3",
"@octokit/core": "^3.6.0",
"@prisma/client": "^5.22.0",
"axios": "^1.7.9",
"bcrypt": "^5.1.1",
"bullmq": "^5.34.4",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"dotenv": "^16.4.7",
"express": "^4.21.1",
"express-rate-limit": "^7.5.0",
"faiss-node": "^0.5.1",
"ioredis": "^5.4.1",
"jsonwebtoken": "^9.0.2",
"kafkajs": "^2.2.4",
"langchain": "^0.3.15",
"octokit": "^4.0.3",
"prisma": "^5.22.0",
"random-word-slugs": "^0.1.7",
"socket.io": "^4.8.1",
"supertest": "^7.0.0",
"uuid": "^11.0.3",
"zod": "^3.23.8"
}

Originally created by @sahil2832005 on GitHub (Feb 13, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] 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 ```python const { StateGraph } = require("@langchain/langgraph"); // const { MemorySaver } = require("@langchain/langgraph"); const { createAgent, llm, memory } = require("../langchainConfig"); const { BaseChannel } = require("@langchain/langgraph/pregel"); // Correct import path // const memorySaver = new MemorySaver(); const graph = new StateGraph({ channels: { chat_history: { value: [], aggregate: "append" // Use built-in aggregation }, deployment_status: { value: "pending" }, ai_response: { value: "" }, user_message: { value: "" }, user: { value: null } }, // memory: new MemorySaver() }); // ===== NODES ===== // graph.addNode("processInputWithLLM", async (state) => { console.log("\n=== LLM Processing ==="); const agent = await createAgent(llm, memory); const result = await agent.invoke({ input: state.user_message }); return { ai_response: result.output }; }); graph.addNode("checkPermissions", async (state) => { console.log("\n=== Checking Permissions ==="); if (!state.user?.hasDeploymentAccess) { throw new Error("User lacks deployment permissions"); } return { deployment_status: "approved" }; }); graph.addNode("triggerDeployment", async (state) => { console.log("\n=== Triggering Deployment ==="); console.log("Received state:", JSON.stringify(state, null, 2)); // Add actual deployment logic here return { deployment_status: "in_progress" }; }); graph.addNode("validateDeployment", async (state) => { console.log("\n=== Validating Deployment ==="); const success = Math.random() > 0.2; // Replace with real validation return { deployment_status: success ? "successful" : "failed" }; }); graph.addNode("logConversation", async (state) => { console.log("\n=== Logging Conversation ==="); return { chat_history: [ ...state.chat_history, `User: ${state.user_message}`, `AI: ${state.ai_response}`, `Status: ${state.deployment_status}` ] }; }); // ===== EDGES ===== // graph.addEdge("processInputWithLLM", "checkPermissions"); graph.addEdge("checkPermissions", "triggerDeployment"); graph.addEdge("triggerDeployment", "validateDeployment"); graph.addEdge("validateDeployment", "logConversation"); // ===== GRAPH CONFIG ===== // graph.setEntryPoint("processInputWithLLM"); graph.setFinishPoint("logConversation"); // Explicit finish point const workflow = graph.compile(); // ===== EXECUTION HANDLER ===== // const runDeploymentWorkflow = async (user, userMessage) => { const initialState = { chat_history: [], deployment_status: "pending", ai_response: "", user_message: userMessage, user: user }; try { console.log("\n=== Starting Workflow ==="); const result = await workflow.invoke(initialState); console.log("\n=== Final State ==="); console.log(JSON.stringify(result, null, 2)); return result; } catch (error) { console.error("Workflow Failed:", error); throw new Error(`Deployment failed: ${error.message}`); } }; module.exports = { runDeploymentWorkflow }; ``` ### Error Message and Stack Trace (if applicable) ```shell Workflow Failed: TypeError: this.operator is not a function at BinaryOperatorAggregate.update (D:\Node js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\channels\binop.cjs:57:35) at _applyWrites (D:\Node js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\algo.cjs:205:46) at PregelLoop.tick (D:\Node js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\loop.cjs:454:67) at CompiledStateGraph._runLoop (D:\Node js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\index.cjs:1010:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async createAndRunLoop (D:\Node js\version control build service\api-server-spinner\node_modules\@langchain\langgraph\dist\pregel\index.cjs:908:17) web hook Worker is ready to process jobs. deployment Worker is ready to process jobs. Failed queue worker is ready to process jobs. ``` ### Description i am trying to use langgraph state graph and it not completes my all node breaks by giving me this response and above mentioned stack strace this.operator is not a function guide me to fix it ### System Info "dependencies": { "@aws-sdk/client-ecs": "^3.693.0", "@clickhouse/client": "^1.8.1", "@langchain/community": "^0.3.29", "@langchain/core": "^0.3.39", "@langchain/groq": "^0.1.3", "@langchain/langgraph": "^0.2.46", "@langchain/openai": "^0.4.3", "@octokit/core": "^3.6.0", "@prisma/client": "^5.22.0", "axios": "^1.7.9", "bcrypt": "^5.1.1", "bullmq": "^5.34.4", "cors": "^2.8.5", "crypto": "^1.0.1", "dotenv": "^16.4.7", "express": "^4.21.1", "express-rate-limit": "^7.5.0", "faiss-node": "^0.5.1", "ioredis": "^5.4.1", "jsonwebtoken": "^9.0.2", "kafkajs": "^2.2.4", "langchain": "^0.3.15", "octokit": "^4.0.3", "prisma": "^5.22.0", "random-word-slugs": "^0.1.7", "socket.io": "^4.8.1", "supertest": "^7.0.0", "uuid": "^11.0.3", "zod": "^3.23.8" }
yindo closed this issue 2026-02-15 17:16:42 -05:00
Author
Owner

@tarangpatel commented on GitHub (Jun 19, 2025):

I am facing same issue. First node working fine. But after it is processed going to nect node giving same error:

Orchestration error: TypeError: this.operator is not a function at BinaryOperatorAggregate.update (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/channels/binop.js:54:35) at _applyWrites (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/algo.js:188:46) at PregelLoop.tick (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/loop.js:566:40) at CompiledStateGraph._runLoop (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/index.js:1536:31) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async createAndRunLoop (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/index.js:1419:17) Error processing request: TypeError: this.operator is not a function at BinaryOperatorAggregate.update (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/channels/binop.js:54:35)

@sahil28032005 you found any solution?

@tarangpatel commented on GitHub (Jun 19, 2025): I am facing same issue. First node working fine. But after it is processed going to nect node giving same error: `Orchestration error: TypeError: this.operator is not a function at BinaryOperatorAggregate.update (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/channels/binop.js:54:35) at _applyWrites (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/algo.js:188:46) at PregelLoop.tick (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/loop.js:566:40) at CompiledStateGraph._runLoop (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/index.js:1536:31) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async createAndRunLoop (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/pregel/index.js:1419:17) Error processing request: TypeError: this.operator is not a function at BinaryOperatorAggregate.update (file:///Users/tarangpatel/Desktop/AI-Testing/server/node_modules/@langchain/langgraph/dist/channels/binop.js:54:35)` @sahil28032005 you found any solution?
Author
Owner

@dqbd commented on GitHub (Jul 8, 2025):

Hello! The definition of the state graph does not seem to be correct (the channels.chat_history should contain reducer and default, not value and aggregate), ie like this:

const graph = new StateGraph<{
  chat_history: BaseMessage[];
}>({
  channels: {
    chat_history: {
      reducer: messagesStateReducer,
      default: () => [],
    },
  },
})

We recommend you using Zod or Annotation to define your state schema, as this format will be deprecated in 1.x

const graph = new StateGraph(
  Annotation.Root({
    chat_history: Annotation({
      reducer: messagesStateReducer,
      default: () => [],
    }),
  }),
)
@dqbd commented on GitHub (Jul 8, 2025): Hello! The definition of the state graph does not seem to be correct (the `channels.chat_history` should contain `reducer` and `default`, not `value` and `aggregate`), ie like this: ```ts const graph = new StateGraph<{ chat_history: BaseMessage[]; }>({ channels: { chat_history: { reducer: messagesStateReducer, default: () => [], }, }, }) ``` We recommend you using Zod or Annotation to define your state schema, as this format will be deprecated in 1.x ```ts const graph = new StateGraph( Annotation.Root({ chat_history: Annotation({ reducer: messagesStateReducer, default: () => [], }), }), ) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#170