From b73d94a5f11f344654fb692a68f2855aef4ca7c8 Mon Sep 17 00:00:00 2001 From: "open-swe[bot]" Date: Mon, 11 Aug 2025 20:07:35 +0000 Subject: [PATCH] Apply patch [skip ci] --- .../langgraph/prebuilt/chat_agent_executor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py index addeedfc6..260e1f5e5 100644 --- a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py @@ -568,7 +568,15 @@ def create_react_agent( ) -> LanguageModelLike: """Resolve the model to use, handling both static and dynamic models.""" if is_dynamic_model: - return _get_prompt_runnable(prompt) | model(state, runtime) # type: ignore[operator] + resolved_model = model(state, runtime) # type: ignore[operator] + if ( + _should_bind_tools(resolved_model, tool_classes, num_builtin=len(llm_builtin_tools)) # type: ignore[arg-type] + and len(tool_classes + llm_builtin_tools) > 0 + ): + resolved_model = cast(BaseChatModel, resolved_model).bind_tools( + tool_classes + llm_builtin_tools # type: ignore[operator] + ) + return _get_prompt_runnable(prompt) | resolved_model else: return static_model @@ -969,3 +977,4 @@ __all__ = [ "AgentStateWithStructuredResponsePydantic", ] +