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

    Agent

    Agent that calls the language model and deciding the action.

    This is driven by a LLMChain. The prompt in the LLMChain MUST include a variable called "agent_scratchpad" where the agent can put its intermediary work.

    Copy
    Agent()

    Bases

    BaseSingleActionAgent

    Attributes

    attribute
    llm_chain: LLMChain

    LLMChain to use for agent.

    attribute
    output_parser: AgentOutputParser

    Output parser to use for agent.

    attribute
    allowed_tools: list[str] | None

    Allowed tools for the agent. If None, all tools are allowed.

    attribute
    return_values: list[str]

    Return values of the agent.

    attribute
    input_keys: list[str]

    Return the input keys.

    attribute
    observation_prefix: str

    Prefix to append the observation with.

    attribute
    llm_prefix: str

    Prefix to append the LLM call with.

    Methods

    method
    dict

    Return dictionary representation of agent.

    method
    get_allowed_tools

    Get allowed tools.

    method
    plan

    Given input, decided what to do.

    method
    aplan

    Async given input, decided what to do.

    method
    get_full_inputs

    Create the full inputs for the LLMChain from intermediate steps.

    method
    validate_prompt

    Validate that prompt matches format.

    method
    create_prompt

    Create a prompt for this class.

    method
    from_llm_and_tools

    Construct an agent from an LLM and tools.

    method
    return_stopped_response

    Return response when agent has been stopped due to max iterations.

    method
    tool_run_logging_kwargs

    Return logging kwargs for tool run.

    Inherited fromBaseSingleActionAgent

    Methods

    Msave
    —

    Save the agent.

    View source on GitHub