LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
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
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
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/langgraph-sdkstreamUseStreamCommonOptionsoptimistic
Property●Since v1.9

optimistic

Optimistic UI for submit(). When enabled (the default), the input passed to submit() is reflected in values / messages immediately — before the server responds — then reconciled against the authoritative server state as it streams in:

  • Messages in the input are appended right away. Any message without an id is assigned a stable client id (sent to the server, which add_messages preserves) so the server echo reconciles by id instead of duplicating. Per-message progress is exposed via useMessageMetadata(stream, id).optimisticStatus ("pending" → "sent", or "failed" if the run errors before the message is echoed; failed optimistic messages are kept for retry UIs and dropped on the next hydrate()).
  • Other input keys are shallow-merged into values and converge to server truth on the first values event (or are rolled back if the run fails before any echo).

Set to false to dispatch input verbatim with no client-side echo or id minting (server-authoritative only) — useful for non-chat state graphs or deterministic SSR/tests.

Copy
optimistic: boolean
View source on GitHub