LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Getting started
  • useStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Suspense
  • StreamProvider & context
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
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

OverviewGetting starteduseStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsSuspenseStreamProvider & contextType safetyMigrating to v1
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
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/reactUseStreamReturnrespond
Methodā—Since v1.0

respond

Copy
respond(response: unknown, options: StreamRespondOptions<ConfigurableType>): Promise<void>
View source on GitHub

Parameters

NameTypeDescription
response*unknown
optionsStreamRespondOptions<ConfigurableType>

Example 1

Example 2

Example 3

Example 4

Example 5

Example 6

Resume a pending protocol interrupt by sending a response payload back to the interrupted namespace.

When options.interruptId is omitted, walks getThread()?.interrupts from newest to oldest and resumes the first not yet resolved by a prior respond() call. That may be a root or subgraph interrupt and is not necessarily interrupt (interrupts[0], root-only). Safe when exactly one interrupt is pending; otherwise pass an explicit options.interruptId (and options.namespace for subgraph interrupts).

The server validates namespace against the pending interrupt. Root interrupts use namespace: [] (default when omitted). For subgraph interrupts, copy namespace from getThread()?.interrupts.

Pass options.config / options.metadata to fold run-level config (model, user context, …) and metadata (trigger source, test flags, …) into the resumed run, mirroring submit().

Pass options.update (and/or options.goto) to apply a state update (and/or directed jump) in the same superstep as the resume — mapped to LangGraph's Command(resume, update, goto). The resumed run produces a single checkpoint reflecting both, so a HITL card can push its message into state at the moment it answers the interrupt (no separate state write, no intermediate checkpoint, no flicker). Messages may be plain dicts or @langchain/core BaseMessage instances (serialized like submit()).

Copy
// Single pending interrupt
await stream.respond({ approved: true });
Copy
// Resolve the interrupt AND push the card's message into state atomically
await stream.respond({ approved: true }, {
  update: { messages: [{ type: "ai", content: "Approved by reviewer." }] },
});
Copy
// `update` also accepts BaseMessage instances, like `submit()`
import { AIMessage } from "@langchain/core/messages";
await stream.respond({ approved: true }, {
  update: { messages: [new AIMessage("Approved by reviewer.")] },
});
Copy
// Resume carrying run config + metadata
await stream.respond({ approved: true }, {
  config: { configurable: { model: "gpt-4o" } },
  metadata: { source: "ui" },
});
Copy
// Multiple root interrupts — one at a time
stream.interrupts.map((intr) => (
  <button
    key={intr.id}
    onClick={() =>
      void stream.respond({ approved: true }, { interruptId: intr.id! })
    }
  />
));
Copy
// Subgraph interrupt — namespace from `getThread()`
const thread = stream.getThread();
thread?.interrupts.map((entry) => (
  <button
    key={entry.interruptId}
    onClick={() =>
      void stream.respond(buildResponse(entry.payload), {
        interruptId: entry.interruptId,
        namespace: entry.namespace,
      })
    }
  />
));