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

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

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

    initialize_agent

    Copy
    initialize_agent(
      tools: Sequence[BaseTool],
      llm: BaseLanguageModel,
      agent: AgentType
    View source on GitHub
    |
    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
    agent_pathstr | None
    Default:None
    agent_kwargsdict | None
    Default:None
    tagsSequence[str] | None
    Default:None
    kwargsAny
    Default:{}

    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.

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

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

    Additional keyword arguments to pass to the underlying agent.

    Tags to apply to the traced runs.

    Additional keyword arguments passed to the agent executor.