From 163f0ee7fd2c9485352780374d94db81d1ac41de Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Wed, 6 Aug 2025 15:11:39 -0400 Subject: [PATCH] attempt fixes --- libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py index 4026ef81f..8b0a3f13a 100644 --- a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py @@ -575,7 +575,7 @@ def create_react_agent( _should_bind_tools(model, tool_classes, num_builtin=len(llm_builtin_tools)) # type: ignore[arg-type] and len(tool_classes + llm_builtin_tools) > 0 ): - model = cast(Union[BaseChatModelV0, BaseChatModelV1], model).bind_tools( + model = cast(Union[BaseChatModelV0, BaseChatModelV1], model).bind_tools( # type: ignore[assignment] tool_classes + llm_builtin_tools # type: ignore[operator] ) @@ -681,6 +681,9 @@ def create_react_agent( else: response = cast(AIMessageV1, response) + # Type assertion to help mypy understand the response type + assert isinstance(response, (AIMessageV0, AIMessageV1)) + # add agent name to the AIMessage response.name = name @@ -714,6 +717,9 @@ def create_react_agent( else: response = cast(AIMessageV1, response) + # Type assertion to help mypy understand the response type + assert isinstance(response, (AIMessageV0, AIMessageV1)) + # add agent name to the AIMessage response.name = name if _are_more_steps_needed(state, response):