From a9df3a351576902f8661698277ffaec62e96b752 Mon Sep 17 00:00:00 2001 From: Vadym Barda Date: Mon, 30 Sep 2024 18:22:48 -0400 Subject: [PATCH] langgraph: use correct logic for binding tools in prebuilt agent (#1927) --- libs/langgraph/langgraph/prebuilt/chat_agent_executor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py b/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py index 21ad0e7b0..0b4edf1d7 100644 --- a/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py @@ -122,10 +122,10 @@ def _get_model_preprocessing_runnable( def _should_bind_tools(model: LanguageModelLike, tools: Sequence[BaseTool]) -> bool: if not isinstance(model, RunnableBinding): - return False + return True if "tools" not in model.kwargs: - return False + return True bound_tools = model.kwargs["tools"] if len(tools) != len(bound_tools): @@ -151,7 +151,7 @@ def _should_bind_tools(model: LanguageModelLike, tools: Sequence[BaseTool]) -> b if missing_tools := tool_names - bound_tool_names: raise ValueError(f"Missing tools '{missing_tools}' in the model.bind_tools()") - return True + return False @deprecated_parameter("messages_modifier", "0.1.9", "state_modifier", removal="0.3.0")