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-classicstorage_lc_storecreate_lc_store
    Function●Since v1.0

    create_lc_store

    Copy
    create_lc_store(
      store: ByteStore,
      *,
      key_encoder: Callable[[str], str] | 
    View source on GitHub
    None
    =
    None
    )
    ->
    BaseStore
    [
    str
    ,
    Serializable
    ]

    Parameters

    NameTypeDescription
    store*ByteStore
    key_encoderCallable[[str], str] | None
    Default:None

    Create a store for LangChain serializable objects from a bytes store.

    Treat the underlying byte store as a trust boundary

    Reads from this store are deserialized with langchain_core.load.loads, which instantiates Python objects from the stored payload. The same threat model applies: a payload can carry constructor kwargs (custom base_url, headers, model name, etc.) that get applied during __init__, so the bytes are effectively executable configuration rather than plain data.

    Never back this store with anything an attacker can write to — for example a shared cache that other tenants can populate, an S3 bucket without strict write controls, or a Redis instance reused across trust boundaries. A single tampered value will instantiate attacker-controlled classes the next time the store is read.

    If you cannot guarantee the store is write-restricted to your own process, use create_kv_docstore instead — it pins allowed_objects=[Document] so a tampered value can at worst produce a Document, never a chat model or LLM with a redirected endpoint.

    A bytes store to use as the underlying store.

    A function to encode keys; if None uses identity function.