LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicagentsinitializeinitialize_agent
    Function●Since v1.0Deprecated

    initialize_agent

    Load an agent executor given tools and LLM.

    Warning

    This function is no deprecated in favor of create_agent from the langchain package, which provides a more flexible agent factory with middleware support, structured output, and integration with LangGraph.

    For migration guidance, see Migrating to langchain v1 and Migrating from AgentExecutor.

    Copy
    initialize_agent(
      tools: Sequence[BaseTool],
      llm: BaseLanguageModel,
      agent: AgentType | None = None,
      callback_manager: BaseCallbackManager | None = None,
      agent_path: str | None = None,
      agent_kwargs: dict | None = None,
      *,
      tags: Sequence[str] | None = None,
      **kwargs: Any = {}
    ) -> AgentExecutor

    Parameters

    NameTypeDescription
    tools*Sequence[BaseTool]

    List of tools this agent has access to.

    llm*BaseLanguageModel

    Language model to use as the agent.

    agentAgentType | None
    Default:None

    Agent type to use. If None and agent_path is also None, will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION.

    callback_managerBaseCallbackManager | None
    Default:None

    CallbackManager to use. Global callback manager is used if not provided.

    agent_pathstr | None
    Default:None

    Path to serialized agent to use. If None and agent is also None, will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION.

    agent_kwargsdict | None
    Default:None

    Additional keyword arguments to pass to the underlying agent.

    tagsSequence[str] | None
    Default:None

    Tags to apply to the traced runs.

    kwargsAny
    Default:{}

    Additional keyword arguments passed to the agent executor.

    View source on GitHub