- By mutability:
- Static context: Immutable data that doesn’t change during execution (e.g., user metadata, database connections, tools)
- Dynamic context: Mutable data that evolves as the application runs (e.g., conversation history, intermediate results, tool call observations)
- By lifetime:
- Runtime context: Data scoped to a single run or invocation
- Cross-conversation context: Data that persists across multiple conversations or sessions
| Context type | Description | Mutability | Lifetime |
|---|---|---|---|
| Config | data passed at the start of a run | Static | Single run |
| Dynamic runtime context (state) | Mutable data that evolves during a single run | Dynamic | Single run |
| Dynamic cross-conversation context (store) | Persistent data shared across conversations | Dynamic | Cross-conversation |
Config
Config is for immutable data like user metadata or API keys. Use this when you have values that don’t change mid-run. Specify configuration using a key called “configurable” which is reserved for this purpose.Dynamic runtime context
Dynamic runtime context represents mutable data that can evolve during a single run and is managed through the LangGraph state object. This includes conversation history, intermediate results, and values derived from tools or LLM outputs. In LangGraph, the state object acts as short-term memory during a run.- In an agent
- In a workflow
Example shows how to incorporate state into an agent prompt.State can also be accessed by the agent’s tools, which can read or update the state as needed. See tool calling guide for details.
Dynamic cross-conversation context
Dynamic cross-conversation context represents persistent, mutable data that spans across multiple conversations or sessions and is managed through the LangGraph store. This includes user profiles, preferences, and historical interactions. The LangGraph store acts as long-term memory across multiple runs. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions).See also
- Memory conceptual overview
- Short-term memory in LangChain
- Long-term memory in LangChain
- Memory in LangGraph