diff --git a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py index 6c3f0a4c0..0f71a981f 100644 --- a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py @@ -254,6 +254,13 @@ def create_react_agent( LanguageModelLike, Callable[[StateSchema, Runtime[ContextT]], BaseChatModel], Callable[[StateSchema, Runtime[ContextT]], Awaitable[BaseChatModel]], + Callable[ + [StateSchema, Runtime[ContextT]], Runnable[LanguageModelInput, BaseMessage] + ], + Callable[ + [StateSchema, Runtime[ContextT]], + Awaitable[Runnable[LanguageModelInput, BaseMessage]], + ], ], tools: Union[Sequence[Union[BaseTool, Callable, dict[str, Any]]], ToolNode], *, @@ -287,6 +294,9 @@ def create_react_agent( - **Dynamic model**: A callable with signature `(state, runtime) -> BaseChatModel` that returns different models based on runtime context + If the model has tools bound via `.bind_tools()` or other configurations, + the return type should be a Runnable[LanguageModelInput, BaseMessage] + Coroutines are also supported, allowing for asynchronous model selection. Dynamic functions receive graph state and runtime, enabling context-dependent model selection. Must return a `BaseChatModel`