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-supervisorCreateSupervisorParams
Type●Since v0.0

CreateSupervisorParams

Copy
CreateSupervisorParams

Properties

View source on GitHub
property
addHandoffBackMessages: boolean
property
agents: CompiledStateGraph<AnnotationRootT["State"], AnnotationRootT["Update"], string, AnnotationRootT["spec"], AnnotationRootT["spec"]> | RemoteGraph[]
property
contextSchema: AnnotationRootT
property
includeAgentName: AgentNameMode
property
llm: LanguageModelLike
property
outputMode: OutputMode
property
postModelHook: CreateReactAgentParams<AnnotationRootT, StructuredResponseFormat>["postModelHook"]
property
preModelHook: CreateReactAgentParams<AnnotationRootT, StructuredResponseFormat>["preModelHook"]
property
prompt: CreateReactAgentParams["prompt"]
property
responseFormat: InteropZodType<StructuredResponseFormat> | __type | Record<string, unknown>
property
stateSchema: AnnotationRootT
property
supervisorName: string
property
tools: StructuredToolInterface | RunnableToolLike | DynamicTool[]

Whether to add a pair of (AIMessage, ToolMessage) to the message history when returning control to the supervisor to indicate that a handoff has occurred

List of agents to manage

Context schema to use for the supervisor graph

Use to specify how to expose the agent name to the underlying supervisor LLM.

  • undefined: Relies on the LLM provider using the name attribute on the AI message. Currently, only OpenAI supports this.
  • "inline": Add the agent name directly into the content field of the AI message using XML-style tags. Example: "How can I help you" -> "agent_nameHow can I help you?"

Language model to use for the supervisor

Mode for adding managed agents' outputs to the message history in the multi-agent workflow. Can be one of:

  • "full_history": add the entire agent message history
  • "last_message": add only the last message (default)

An optional node to add after the LLM node in the supervisor agent (i.e., the node that calls the LLM). Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing. Post-model hook must be a callable or a runnable that takes in current graph state and returns a state update.

An optional prompt for the supervisor. Can be one of:

  • string: This is converted to a SystemMessage and added to the beginning of the list of messages in state["messages"]
  • SystemMessage: this is added to the beginning of the list of messages in state["messages"]
  • Function: This function should take in full graph state and the output is then passed to the language model
  • Runnable: This runnable should take in full graph state and the output is then passed to the language model

An optional schema for the final supervisor output.

If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key. If not provided, structuredResponse will not be present in the output state.

Can be passed in as:

  • Zod schema
  • JSON schema
  • { prompt, schema }, where schema is one of the above. The prompt will be used together with the model that is being used to generate the structured response.

Important: responseFormat requires the model to support .withStructuredOutput().

Note: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished. This is not the only strategy to get structured responses, see more options in this guide.

State schema to use for the supervisor graph

Name of the supervisor node

Tools to use for the supervisor

An optional node to add before the LLM node in the supervisor agent (i.e., the node that calls the LLM). Useful for managing long message histories (e.g., message trimming, summarization, etc.).

Pre-model hook must be a callable or a runnable that takes in current graph state and returns a state update in the form of:

{
  messages: [new RemoveMessage({ id: REMOVE_ALL_MESSAGES }), ...],
  llmInputMessages: [...]
  ...
}

Important: At least one of messages or llmInputMessages MUST be provided and will be used as an input to the agent node. The rest of the keys will be added to the graph state.

Warning: If you are returning messages in the pre-model hook, you should OVERWRITE the messages key by doing the following:

{ messages: [new RemoveMessage({ id: REMOVE_ALL_MESSAGES }), ...newMessages], ... }