From 956bdc912f86d17cbf1f0ddd349135a0efc362de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=9B=E9=9C=B2=E5=85=88=E7=94=9F?= Date: Tue, 19 May 2026 05:26:09 +0800 Subject: [PATCH] refactor(langchain): clean redundancy ifelse. (#37448) Signed-off-by: zhanluxianshen --- libs/langchain_v1/langchain/agents/factory.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libs/langchain_v1/langchain/agents/factory.py b/libs/langchain_v1/langchain/agents/factory.py index b66d650f3fd..a245a4d4bef 100644 --- a/libs/langchain_v1/langchain/agents/factory.py +++ b/libs/langchain_v1/langchain/agents/factory.py @@ -867,11 +867,8 @@ def create_agent( initial_response_format: ToolStrategy[Any] | ProviderStrategy[Any] | AutoStrategy[Any] | None if response_format is None: initial_response_format = None - elif isinstance(response_format, (ToolStrategy, ProviderStrategy)): - # Preserve explicitly requested strategies - initial_response_format = response_format - elif isinstance(response_format, AutoStrategy): - # AutoStrategy provided - preserve it for later auto-detection + elif isinstance(response_format, (ToolStrategy, ProviderStrategy, AutoStrategy)): + # Explicit Tool/Provider strategy, or AutoStrategy for later capability detection initial_response_format = response_format else: # Raw schema - wrap in AutoStrategy to enable auto-detection