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-classicagentsagentAgentExecutor
    Class●Since v1.0

    AgentExecutor

    Copy
    AgentExecutor()

    Bases

    Chain

    Used in Docs

    • Amadeus toolkit integration
    • ArXiv integration
    • Asknews integration
    • Azure AI services toolkit integration
    • Azure container apps dynamic sessions integration
    (15 more not shown)

    Attributes

    Methods

    Inherited fromChain

    Attributes

    Amemory: BaseMemory | None
    —

    Optional memory object.

    Acallbacks: CallbacksAverbose: boolAtags
    View source on GitHub
    : list[str] | None
    Ametadata: dict[str, Any] | None
    Acallback_manager: BaseCallbackManager | None
    —

    [DEPRECATED] Use callbacks instead.

    Amodel_config

    Methods

    Mget_input_schemaMget_output_schemaMinvokeMainvokeMraise_callback_manager_deprecation
    —

    Raise deprecation warning if callback_manager is used.

    Mset_verbose
    —

    Set the chain verbosity.

    Macall
    —

    Asynchronously execute the chain.

    Mprep_outputs
    —

    Validate and prepare chain outputs, and save info about this run to memory.

    Maprep_outputs
    —

    Validate and prepare chain outputs, and save info about this run to memory.

    Mprep_inputs
    —

    Prepare chain inputs, including adding inputs from memory.

    Maprep_inputs
    —

    Prepare chain inputs, including adding inputs from memory.

    Mrun
    —

    Convenience method for executing chain.

    Marun
    —

    Convenience method for executing chain.

    Mdict
    —

    Return dictionary representation of agent.

    Mapply
    —

    Utilize the LLM generate method for speed gains.

    Inherited fromRunnableSerializable(langchain_core)

    Attributes

    AnameAmodel_config

    Methods

    Mto_jsonMconfigurable_fieldsMconfigurable_alternatives

    Inherited fromSerializable(langchain_core)

    Attributes

    Alc_secretsAlc_attributesAmodel_config

    Methods

    Mis_lc_serializableMget_lc_namespaceMlc_idMto_jsonMto_json_not_implemented

    Inherited fromRunnable(langchain_core)

    Attributes

    AnameAInputTypeAOutputTypeAinput_schemaAoutput_schemaAconfig_specs

    Methods

    Mget_nameMget_input_schemaMget_input_jsonschemaMget_output_schemaMget_output_jsonschemaM
    attribute
    agent: BaseSingleActionAgent | BaseMultiActionAgent | Runnable

    The agent to run for creating a plan and determining actions to take at each step of the execution loop.

    attribute
    tools: Sequence[BaseTool]

    The valid tools the agent can call.

    attribute
    return_intermediate_steps: bool

    Whether to return the agent's trajectory of intermediate steps at the end in addition to the final output.

    attribute
    max_iterations: int | None

    The maximum number of steps to take before ending the execution loop.

    Setting to 'None' could lead to an infinite loop.

    attribute
    max_execution_time: float | None

    The maximum amount of wall clock time to spend in the execution loop.

    attribute
    early_stopping_method: str

    The method to use for early stopping if the agent never returns AgentFinish. Either 'force' or 'generate'.

    "force" returns a string saying that it stopped because it met a time or iteration limit.

    "generate" calls the agent's LLM Chain one final time to generate a final answer based on the previous steps.

    attribute
    handle_parsing_errors: bool | str | Callable[[OutputParserException], str]

    How to handle errors raised by the agent's output parser. Defaults to False, which raises the error. If true, the error will be sent back to the LLM as an observation. If a string, the string itself will be sent to the LLM as an observation. If a callable function, the function will be called with the exception as an argument, and the result of that function will be passed to the agent as an observation.

    attribute
    trim_intermediate_steps: int | Callable[[list[tuple[AgentAction, str]]], list[tuple[AgentAction, str]]]

    How to trim the intermediate steps before returning them. Defaults to -1, which means no trimming.

    attribute
    input_keys: list[str]

    Return the input keys.

    attribute
    output_keys: list[str]

    Return the singular output key.

    method
    from_agent_and_tools

    Create from agent and tools.

    method
    validate_tools

    Validate that tools are compatible with agent.

    method
    validate_runnable_agent

    Convert runnable to agent if passed in.

    method
    save

    Raise error - saving not supported for Agent Executors.

    method
    save_agent

    Save the underlying agent.

    method
    iter

    Enables iteration over steps taken to reach final output.

    method
    lookup_tool

    Lookup tool by name.

    method
    stream

    Enables streaming over steps taken to reach final output.

    method
    astream

    Async enables streaming over steps taken to reach final output.

    Agent that is using tools.

    config_schema
    Mget_config_jsonschema
    Mget_graph
    Mget_prompts
    Mpipe
    Mpick
    Massign
    Minvoke
    Mainvoke
    Mbatch
    Mbatch_as_completed
    Mabatch
    Mabatch_as_completed
    Mastream_log
    Mastream_events
    Mtransform
    Matransform
    Mbind
    Mwith_config
    Mwith_listeners
    Mwith_alisteners
    Mwith_types
    Mwith_retry
    Mmap
    Mwith_fallbacks
    Mas_tool