LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coreloadLoadOptions
Interfaceā—Since v1.1

LoadOptions

Options for loading serialized LangChain objects.

Copy
interface LoadOptions

Security considerations:

Deserialization can instantiate arbitrary classes from the allowed namespaces. When loading untrusted data, be aware that:

  1. secretsFromEnv: Defaults to false. Setting to true allows the deserializer to read environment variables, which could leak secrets if the serialized data contains malicious secret references.

  2. importMap / optionalImportsMap: These allow extending which classes can be instantiated. Never populate these from user input. Only include modules you explicitly trust.

  3. Class instantiation: Allowed classes will have their constructors called with the deserialized kwargs. If a class performs side effects in its constructor (network calls, file I/O, etc.), those will execute.

Properties

property
importMap: Record<string, unknown>

Additional import map for the "langchain" namespace.

Security warning: This extends which classes can be instantiated during deserialization. Never populate this map with values derived from user input. Only include modules that you explicitly trust and have reviewed.

Any class exposed through this map can be instantiated with attacker-controlled kwargs if the serialized data is untrusted.

property
maxDepth: number

Maximum recursion depth allowed during deserialization.

This limit protects against denial-of-service attacks using deeply nested JSON structures that could cause stack overflow. If your legitimate data requires deeper nesting, you can increase this limit.

property
optionalImportEntrypoints: string[]

Additional optional import entrypoints to allow beyond the defaults.

Security warning: This extends which namespace paths are considered valid for deserialization. Never populate this array with values derived from user input. Each entrypoint you add expands the attack surface for deserialization.

property
optionalImportsMap: OptionalImportMap

A map of optional imports. Keys are namespace paths (e.g., "langchain_community/llms"), values are the imported modules.

Security warning: This extends which classes can be instantiated during deserialization. Never populate this map with values derived from user input. Only include modules that you explicitly trust and have reviewed.

Classes in these modules can be instantiated with attacker-controlled kwargs if the serialized data is untrusted.

property
secretsFromEnv: boolean

Whether to load secrets from environment variables when not found in secretsMap.

Security warning: Setting this to true allows the deserializer to read environment variables, which could be a security risk if the serialized data is not trusted. Only set this to true when deserializing data from trusted sources (e.g., your own database, not user input).

property
secretsMap: SecretMap

A map of secrets to load. Keys are secret identifiers, values are the secret values.

If a secret is not found in this map and secretsFromEnv is false, an error is thrown. If secretsFromEnv is true, the secret will be loaded from environment variables (if not found there either, an error is thrown).

View source on GitHub