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

    ConversationStringBufferMemory

    Copy
    ConversationStringBufferMemory()

    Bases

    BaseMemory

    Attributes

    Methods

    Inherited fromBaseMemory

    Attributes

    Amodel_config

    Inherited fromSerializable(langchain_core)

    Attributes

    Alc_secretsAlc_attributes
    View source on GitHub
    A
    model_config

    Methods

    Mis_lc_serializableMget_lc_namespaceMlc_idMto_jsonMto_json_not_implemented
    attribute
    human_prefix: str
    attribute
    ai_prefix: str
    attribute
    buffer: str
    attribute
    output_key: str | None
    attribute
    input_key: str | None
    attribute
    memory_key: str
    attribute
    memory_variables: list[str]
    method
    validate_chains
    method
    load_memory_variables
    method
    aload_memory_variables
    method
    save_context
    method
    asave_context
    method
    clear
    method
    aclear

    A basic memory implementation that simply stores the conversation history.

    This stores the entire conversation history in memory without any additional processing.

    Equivalent to ConversationBufferMemory but tailored more specifically for string-based conversations rather than chat models.

    Note that additional processing may be required in some situations when the conversation history is too large to fit in the context window of the model.

    Prefix to use for AI generated responses.

    Will always return list of memory variables.

    Validate that return messages is not True.

    Return history buffer.

    Return history buffer.

    Save context from this conversation to buffer.

    Save context from this conversation to buffer.

    Clear memory contents.