Dynamic Breakpoints - Interrupts is empty #143

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

Originally created by @CristianMR on GitHub (Dec 5, 2024).

I'm replicating documentation code in "@langchain/langgraph": "^0.2.25" and interrupts is empty.

Reference code in documentation: dynamic_breakpoints

Output where interrupts is expected is:

[ 'step2' ]
[
  {
    "id": "55297375-aec2-55a4-ade5-3fc9fff9a060",
    "name": "step2",
    "path": [
      "__pregel_pull",
      "step2"
    ],
    "interrupts": []
  }
]

Example code:

import {
  Annotation,
  MemorySaver,
  NodeInterrupt,
  StateGraph,
} from "@langchain/langgraph";

const StateAnnotation = Annotation.Root({
  input: Annotation<string>,
});

const step1 = async (state: typeof StateAnnotation.State) => {
  console.log("---Step 1---");
  return state;
};

const step2 = async (state: typeof StateAnnotation.State) => {
  // Let's optionally raise a NodeInterrupt
  // if the length of the input is longer than 5 characters
  if (state.input?.length > 5) {
    throw new NodeInterrupt(`Received input that is longer than 5 characters: ${state.input}`);
  }
  console.log("---Step 2---");
  return state;
};

const step3 = async (state: typeof StateAnnotation.State) => {
  console.log("---Step 3---");
  return state;
};

const checkpointer = new MemorySaver();

const graph = new StateGraph(StateAnnotation)
  .addNode("step1", step1)
  .addNode("step2", step2)
  .addNode("step3", step3)
  .addEdge("__start__", "step1")
  .addEdge("step1", "step2")
  .addEdge("step2", "step3")
  .addEdge("step3", "__end__")
  .compile({ checkpointer });

const initialInput = { input: "helloooooooo its me!" };
const config = {
  configurable: {
    thread_id: "1",
  },
  streamMode: "values" as const,
};

const stream = await graph.stream(initialInput, config);

for await (const event of stream) {
  console.log(event);

  const state = await graph.getState(config);

  console.log(state.next);
  console.log(JSON.stringify(state.tasks, null, 2));
}

Originally created by @CristianMR on GitHub (Dec 5, 2024). I'm replicating documentation code in `"@langchain/langgraph": "^0.2.25"` and interrupts is empty. Reference code in documentation: [dynamic_breakpoints](https://langchain-ai.github.io/langgraphjs/how-tos/dynamic_breakpoints) Output where interrupts is expected is: ```js [ 'step2' ] [ { "id": "55297375-aec2-55a4-ade5-3fc9fff9a060", "name": "step2", "path": [ "__pregel_pull", "step2" ], "interrupts": [] } ] ``` Example code: ```ts import { Annotation, MemorySaver, NodeInterrupt, StateGraph, } from "@langchain/langgraph"; const StateAnnotation = Annotation.Root({ input: Annotation<string>, }); const step1 = async (state: typeof StateAnnotation.State) => { console.log("---Step 1---"); return state; }; const step2 = async (state: typeof StateAnnotation.State) => { // Let's optionally raise a NodeInterrupt // if the length of the input is longer than 5 characters if (state.input?.length > 5) { throw new NodeInterrupt(`Received input that is longer than 5 characters: ${state.input}`); } console.log("---Step 2---"); return state; }; const step3 = async (state: typeof StateAnnotation.State) => { console.log("---Step 3---"); return state; }; const checkpointer = new MemorySaver(); const graph = new StateGraph(StateAnnotation) .addNode("step1", step1) .addNode("step2", step2) .addNode("step3", step3) .addEdge("__start__", "step1") .addEdge("step1", "step2") .addEdge("step2", "step3") .addEdge("step3", "__end__") .compile({ checkpointer }); const initialInput = { input: "helloooooooo its me!" }; const config = { configurable: { thread_id: "1", }, streamMode: "values" as const, }; const stream = await graph.stream(initialInput, config); for await (const event of stream) { console.log(event); const state = await graph.getState(config); console.log(state.next); console.log(JSON.stringify(state.tasks, null, 2)); } ```
yindo closed this issue 2026-02-15 17:16:14 -05:00
Author
Owner

@jacoblee93 commented on GitHub (Dec 5, 2024):

Hey @CristianMR,

You need to wait until the step has finished before calling getState:

for await (const event of stream) {
  console.log(event);
}

const state = await graph.getState(config);

console.log(state.next);
console.log(JSON.stringify(state.tasks, null, 2));

Basically call after the loop has finished.

@jacoblee93 commented on GitHub (Dec 5, 2024): Hey @CristianMR, You need to wait until the step has finished before calling `getState`: ```ts for await (const event of stream) { console.log(event); } const state = await graph.getState(config); console.log(state.next); console.log(JSON.stringify(state.tasks, null, 2)); ``` Basically call after the loop has finished.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#143