The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
langchain[patch]: update deprecation message for agent classes and constructors (#28369)
ccurme8adc4a5bcc42
diff --git a/libs/langchain/langchain/_api/deprecation.py b/libs/langchain/langchain/_api/deprecation.pyindex e85ab4046c..ecd5a71b89 100644--- a/libs/langchain/langchain/_api/deprecation.py+++ b/libs/langchain/langchain/_api/deprecation.py@@ -7,7 +7,20 @@ from langchain_core._api.deprecation import (warn_deprecated,)+AGENT_DEPRECATION_WARNING = (+ "LangChain agents will continue to be supported, but it is recommended for new "+ "use cases to be built with LangGraph. LangGraph offers a more flexible and "+ "full-featured framework for building agents, including support for "+ "tool-calling, persistence of state, and human-in-the-loop workflows. See "+ "LangGraph documentation for more details: "+ "https://langchain-ai.github.io/langgraph/. Refer here for its pre-built "+ "ReAct agent: "+ "https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/"+)++__all__ = [+ "AGENT_DEPRECATION_WARNING","LangChainDeprecationWarning","LangChainPendingDeprecationWarning","deprecated",diff --git a/libs/langchain/langchain/agents/agent.py b/libs/langchain/langchain/agents/agent.pyindex 500e884cd7..6d1facd3e5 100644--- a/libs/langchain/langchain/agents/agent.py+++ b/libs/langchain/langchain/agents/agent.py@@ -47,6 +47,7 @@ from langchain_core.utils.input import get_color_mappingfrom pydantic import BaseModel, ConfigDict, model_validatorfrom typing_extensions import Self+from langchain._api.deprecation import AGENT_DEPRECATION_WARNINGfrom langchain.agents.agent_iterator import AgentExecutorIteratorfrom langchain.agents.agent_types import AgentTypefrom langchain.agents.tools import InvalidTool@@ -633,10 +634,7 @@ class RunnableMultiActionAgent(BaseMultiActionAgent):@deprecated("0.1.0",- message=(- "Use new agent constructor methods like create_react_agent, create_json_agent, "- "create_structured_chat_agent, etc."- ),+ message=AGENT_DEPRECATION_WARNING,removal="1.0",)class LLMSingleActionAgent(BaseSingleActionAgent):@@ -724,10 +722,7 @@ class LLMSingleActionAgent(BaseSingleActionAgent):@deprecated("0.1.0",- message=(- "Use new agent constructor methods like create_react_agent, create_json_agent, "- "create_structured_chat_agent, etc."- ),+ message=AGENT_DEPRECATION_WARNING,removal="1.0",)class Agent(BaseSingleActionAgent):diff --git a/libs/langchain/langchain/agents/agent_toolkits/vectorstore/base.py b/libs/langchain/langchain/agents/agent_toolkits/vectorstore/base.pyindex eb8548cc6e..4a3e6e76f6 100644--- a/libs/langchain/langchain/agents/agent_toolkits/vectorstore/base.py+++ b/libs/langchain/langchain/agents/agent_toolkits/vectorstore/base.py@@ -20,6 +20,10 @@ from langchain.chains.llm import LLMChainsince="0.2.13",removal="1.0",message=(+ "This function will continue to be supported, but it is recommended for new "+ "use cases to be built with LangGraph. LangGraph offers a more flexible and "+ "full-featured framework for building agents, including support for "+ "tool-calling, persistence of state, and human-in-the-loop workflows. ""See API reference for this function for a replacement implementation: ""https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.vectorstore.base.create_vectorstore_agent.html " # noqa: E501"Read more here on how to create agents that query vector stores: "@@ -109,6 +113,10 @@ def create_vectorstore_agent(since="0.2.13",removal="1.0",message=(+ "This function will continue to be supported, but it is recommended for new "+ "use cases to be built with LangGraph. LangGraph offers a more flexible and "+ "full-featured framework for building agents, including support for "+ "tool-calling, persistence of state, and human-in-the-loop workflows. ""See API reference for this function for a replacement implementation: ""https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.vectorstore.base.create_vectorstore_router_agent.html " # noqa: E501"Read more here on how to create agents that query vector stores: "diff --git a/libs/langchain/langchain/agents/agent_types.py b/libs/langchain/langchain/agents/agent_types.pyindex 14844a2a38..e6a72a98ae 100644--- a/libs/langchain/langchain/agents/agent_types.py+++ b/libs/langchain/langchain/agents/agent_types.py@@ -4,13 +4,12 @@ from enum import Enumfrom langchain_core._api import deprecated+from langchain._api.deprecation import AGENT_DEPRECATION_WARNING+@deprecated("0.1.0",- message=(- "Use new agent constructor methods like create_react_agent, create_json_agent, "- "create_structured_chat_agent, etc."- ),+ message=AGENT_DEPRECATION_WARNING,removal="1.0",)class AgentType(str, Enum):diff --git a/libs/langchain/langchain/agents/chat/base.py b/libs/langchain/langchain/agents/chat/base.pyindex 00ced776f1..22f8e77c5c 100644--- a/libs/langchain/langchain/agents/chat/base.py+++ b/libs/langchain/langchain/agents/chat/base.py@@ -13,6 +13,7 @@ from langchain_core.prompts.chat import (from langchain_core.tools import BaseToolfrom pydantic import Field+from langchain._api.deprecation import AGENT_DEPRECATION_WARNINGfrom langchain.agents.agent import Agent, AgentOutputParserfrom langchain.agents.chat.output_parser import ChatOutputParserfrom langchain.agents.chat.prompt import (@@ -25,7 +26,11 @@ from langchain.agents.utils import validate_tools_single_inputfrom langchain.chains.llm import LLMChain-@deprecated("0.1.0", alternative="create_react_agent", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class ChatAgent(Agent):"""Chat Agent."""diff --git a/libs/langchain/langchain/agents/conversational/base.py b/libs/langchain/langchain/agents/conversational/base.pyindex a0ef85946a..6d7fc0312b 100644--- a/libs/langchain/langchain/agents/conversational/base.py+++ b/libs/langchain/langchain/agents/conversational/base.py@@ -11,6 +11,7 @@ from langchain_core.prompts import PromptTemplatefrom langchain_core.tools import BaseToolfrom pydantic import Field+from langchain._api.deprecation import AGENT_DEPRECATION_WARNINGfrom langchain.agents.agent import Agent, AgentOutputParserfrom langchain.agents.agent_types import AgentTypefrom langchain.agents.conversational.output_parser import ConvoOutputParser@@ -19,7 +20,11 @@ from langchain.agents.utils import validate_tools_single_inputfrom langchain.chains import LLMChain-@deprecated("0.1.0", alternative="create_react_agent", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class ConversationalAgent(Agent):"""An agent that holds a conversation in addition to using tools."""diff --git a/libs/langchain/langchain/agents/initialize.py b/libs/langchain/langchain/agents/initialize.pyindex 17765e9227..cbcf06c5a3 100644--- a/libs/langchain/langchain/agents/initialize.py+++ b/libs/langchain/langchain/agents/initialize.py@@ -7,6 +7,7 @@ from langchain_core.callbacks import BaseCallbackManagerfrom langchain_core.language_models import BaseLanguageModelfrom langchain_core.tools import BaseTool+from langchain._api.deprecation import AGENT_DEPRECATION_WARNINGfrom langchain.agents.agent import AgentExecutorfrom langchain.agents.agent_types import AgentTypefrom langchain.agents.loading import AGENT_TO_CLASS, load_agent@@ -14,10 +15,7 @@ from langchain.agents.loading import AGENT_TO_CLASS, load_agent@deprecated("0.1.0",- alternative=(- "Use new agent constructor methods like create_react_agent, create_json_agent, "- "create_structured_chat_agent, etc."- ),+ message=AGENT_DEPRECATION_WARNING,removal="1.0",)def initialize_agent(diff --git a/libs/langchain/langchain/agents/mrkl/base.py b/libs/langchain/langchain/agents/mrkl/base.pyindex cc4d9da553..538a0bc828 100644--- a/libs/langchain/langchain/agents/mrkl/base.py+++ b/libs/langchain/langchain/agents/mrkl/base.py@@ -12,6 +12,7 @@ from langchain_core.tools import BaseTool, Toolfrom langchain_core.tools.render import render_text_descriptionfrom pydantic import Field+from langchain._api.deprecation import AGENT_DEPRECATION_WARNINGfrom langchain.agents.agent import Agent, AgentExecutor, AgentOutputParserfrom langchain.agents.agent_types import AgentTypefrom langchain.agents.mrkl.output_parser import MRKLOutputParser@@ -34,7 +35,11 @@ class ChainConfig(NamedTuple):action_description: str-@deprecated("0.1.0", alternative="create_react_agent", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class ZeroShotAgent(Agent):"""Agent for the MRKL chain.@@ -168,7 +173,11 @@ class ZeroShotAgent(Agent):super()._validate_tools(tools)-@deprecated("0.1.0", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class MRKLChain(AgentExecutor):"""Chain that implements the MRKL system."""diff --git a/libs/langchain/langchain/agents/react/base.py b/libs/langchain/langchain/agents/react/base.pyindex 81a38141fe..1f9191ab7b 100644--- a/libs/langchain/langchain/agents/react/base.py+++ b/libs/langchain/langchain/agents/react/base.py@@ -11,6 +11,7 @@ from langchain_core.prompts import BasePromptTemplatefrom langchain_core.tools import BaseTool, Toolfrom pydantic import Field+from langchain._api.deprecation import AGENT_DEPRECATION_WARNINGfrom langchain.agents.agent import Agent, AgentExecutor, AgentOutputParserfrom langchain.agents.agent_types import AgentTypefrom langchain.agents.react.output_parser import ReActOutputParser@@ -22,7 +23,11 @@ if TYPE_CHECKING:from langchain_community.docstore.base import Docstore-@deprecated("0.1.0", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class ReActDocstoreAgent(Agent):"""Agent for the ReAct chain."""@@ -69,7 +74,11 @@ class ReActDocstoreAgent(Agent):return "Thought:"-@deprecated("0.1.0", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class DocstoreExplorer:"""Class to assist with exploration of a document store."""@@ -119,7 +128,11 @@ class DocstoreExplorer:return self.document.page_content.split("\n\n")-@deprecated("0.1.0", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class ReActTextWorldAgent(ReActDocstoreAgent):"""Agent for the ReAct TextWorld chain."""@@ -139,7 +152,11 @@ class ReActTextWorldAgent(ReActDocstoreAgent):raise ValueError(f"Tool name should be Play, got {tool_names}")-@deprecated("0.1.0", removal="1.0")+@deprecated(+ "0.1.0",+ message=AGENT_DEPRECATION_WARNING,+ removal="1.0",+)class ReActChain(AgentExecutor):"""[Deprecated] Chain that implements the ReAct paper."""