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-classicagentsagent_toolkitsconversational_retrievalopenai_functionscreate_conversational_retrieval_agent
    Functionā—Since v1.0

    create_conversational_retrieval_agent

    Copy
    create_conversational_retrieval_agent(
      llm: BaseLanguageModel,
      tools: list[BaseTool],
      remember_intermediate_steps: bool
    View source on GitHub
    =
    True
    ,
    memory_key
    :
    str
    =
    'chat_history'
    ,
    system_message
    :
    SystemMessage
    |
    None
    =
    None
    ,
    verbose
    :
    bool
    =
    False
    ,
    max_token_limit
    :
    int
    =
    2000
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    AgentExecutor

    Parameters

    NameTypeDescription
    llm*BaseLanguageModel

    The language model to use, should be ChatOpenAI

    tools*list[BaseTool]

    A list of tools the agent has access to

    remember_intermediate_stepsbool
    Default:True

    Whether the agent should remember intermediate steps or not. Intermediate steps refer to prior action/observation pairs from previous questions. The benefit of remembering these is if there is relevant information in there, the agent can use it to answer follow up questions. The downside is it will take up more tokens.

    memory_keystr
    Default:'chat_history'
    system_messageSystemMessage | None
    Default:None
    verbosebool
    Default:False
    max_token_limitint
    Default:2000
    **kwargsAny
    Default:{}

    A convenience method for creating a conversational retrieval agent.

    The name of the memory key in the prompt.

    The system message to use. By default, a basic one will be used.

    Whether or not the final AgentExecutor should be verbose or not.

    The max number of tokens to keep around in memory.

    Additional keyword arguments to pass to the AgentExecutor.