langgraph_agent_toolkit.agents.components.creators.create_react_agent module

langgraph_agent_toolkit.agents.components.creators.create_react_agent.create_react_agent(model, tools, *, prompt=None, response_format=None, pre_model_hook=None, state_schema=None, config_schema=None, checkpointer=None, store=None, interrupt_before=None, interrupt_after=None, debug=False, version='v1', name=None, immediate_step_threshold=5, immediate_generation_prompt=None)[source][source]

Create a tool-calling chat-model graph with a router.

The router checks the remaining steps. It routes to the agent or the immediate-generation node.

Parameters:
  • model (str | Runnable[PromptValue | str | Sequence[BaseMessage | list[str] | tuple[str, str | list[str | dict[str, Any]]] | str | dict[str, Any]], BaseMessage | str]) – The LangChain chat model that supports tool calling.

  • tools (Sequence[BaseTool | Callable] | ToolNode) – A list of tools or a ToolNode instance.

  • prompt (SystemMessage | str | Callable[[Any], PromptValue | str | Sequence[BaseMessage | list[str] | tuple[str, str | list[str | dict[str, Any]]] | str | dict[str, Any]]] | Runnable[Any, PromptValue | str | Sequence[BaseMessage | list[str] | tuple[str, str | list[str | dict[str, Any]]] | str | dict[str, Any]]] | None) – An optional prompt for the model.

  • response_format (dict | type[BaseModel] | tuple[str, dict | type[BaseModel]] | None) – An optional schema for the final agent output.

  • pre_model_hook (Runnable[Input, Output] | Callable[[Input], Output] | Callable[[Input], Awaitable[Output]] | Callable[[Iterator[Input]], Iterator[Output]] | Callable[[AsyncIterator[Input]], AsyncIterator[Output]] | _RunnableCallableSync[Input, Output] | _RunnableCallableAsync[Input, Output] | _RunnableCallableIterator[Input, Output] | _RunnableCallableAsyncIterator[Input, Output] | Mapping[str, Any] | _RunnableWithWriter[Input, Output] | _RunnableWithStore[Input, Output] | _RunnableWithWriterStore[Input, Output] | _RunnableWithConfigWriter[Input, Output] | _RunnableWithConfigStore[Input, Output] | _RunnableWithConfigWriterStore[Input, Output] | None) – An optional node before the agent node.

  • state_schema (Type[Any] | None) – An optional schema that defines the graph state.

  • config_schema (Type[Any] | None) – An optional schema for configuration.

  • checkpointer (None | bool | BaseCheckpointSaver) – An optional checkpoint saver object.

  • store (BaseStore | None) – An optional store object.

  • interrupt_before (list[str] | None) – An optional list of node names to interrupt before.

  • interrupt_after (list[str] | None) – An optional list of node names to interrupt after.

  • debug (bool) – Enable debug mode.

  • version (Literal['v1', 'v2']) – The graph version: v1 or v2.

  • name (str | None) – An optional name for the CompiledStateGraph.

  • immediate_step_threshold (int) – Use immediate generation below this number of remaining steps.

  • immediate_generation_prompt (str | None) – An optional prompt for immediate generation. The default prompt tells the model to give a direct answer.

Returns:

A compiled LangChain runnable for chat interactions.

Return type:

CompiledStateGraph