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/langgraph-sdkreactSubagentManagerreconstructFromMessages
Method●Since v1.6

reconstructFromMessages

Reconstruct subagent state from historical messages.

This method parses an array of messages (typically from thread history) to identify subagent executions and their results. It's used to restore subagent state after:

  • Page refresh (when stream has already completed)
  • Loading thread history
  • Navigating between threads

The reconstruction process:

  1. Find AI messages with tool calls matching subagent tool names
  2. Find corresponding tool messages with results
  3. Create SubagentStream entries with "complete" status

Note: Internal subagent messages (their streaming conversation) are not reconstructed since they are not persisted in the main thread state.

Copy
reconstructFromMessages(messages: Message<DefaultToolCall>[], options: __type)

Parameters

NameTypeDescription
messages*Message<DefaultToolCall>[]

Array of messages from thread history

options__type

Optional configuration

View source on GitHub