Alpha Notice: These docs cover the v1-alpha release. Content is incomplete and subject to change.For the latest stable version, see the current LangGraph Python or LangGraph JavaScript docs.
- 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
Runtime context refers to local context: data and dependencies your code needs to run. It does not refer to:
- The LLM context, which is the data passed into the LLM’s prompt.
- The “context window”, which is the maximum number of tokens that can be passed to the LLM.
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.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.
- Define a custom state schema that adds additional fields alongside the existing
messages
field. - Pass the custom state schema to the agent. This allows the agent to access and modify the state during execution.
Turning on memory
Please see the memory guide for more details on how to enable memory. This is a powerful feature that allows you to persist the agent’s state across multiple invocations. Otherwise, the state is scoped only to a single run.