LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraphindexinterrupt
Function●Since v0.3

interrupt

Interrupts the execution of a graph node. This function can be used to pause execution of a node, and return the value of the resume input when the graph is re-invoked using Command. Multiple interrupts can be called within a single node, and each will be handled sequentially.

When an interrupt is called:

  1. If there's a resume value available (from a previous Command), it returns that value.
  2. Otherwise, it throws a GraphInterrupt with the provided value
  3. The graph can be resumed by passing a Command with a resume value

Because the interrupt function propagates by throwing a special GraphInterrupt error, you should avoid using try/catch blocks around the interrupt function, or if you do, ensure that the GraphInterrupt error is thrown again within your catch block.

Copy
interrupt<I = unknown, R = any>(value: I): R

Used in Docs

  • Build a custom SQL agent
  • Choosing between Graph and Functional APIs
  • Functional API overview
  • Human-in-the-loop
  • Interrupts

Parameters

NameTypeDescription
value*I

The value to include in the interrupt. This will be available in task.interrupts[].value

Example

Copy
// Define a node that uses multiple interrupts
const nodeWithInterrupts = () => {
  // First interrupt - will pause execution and include {value: 1} in task values
  const answer1 = interrupt({ value: 1 });

  // Second interrupt - only called after first interrupt is resumed
  const answer2 = interrupt({ value: 2 });

  // Use the resume values
  return { myKey: answer1 + " " + answer2 };
};

// Resume the graph after first interrupt
await graph.stream(new Command({ resume: "answer 1" }));

// Resume the graph after second interrupt
await graph.stream(new Command({ resume: "answer 2" }));
// Final result: { myKey: "answer 1 answer 2" }
View source on GitHub