From d88ca6f649397fe079da4ba048ad91e2b5377fed Mon Sep 17 00:00:00 2001 From: Lance Martin Date: Mon, 28 Jul 2025 15:15:45 -0700 Subject: [PATCH 01/10] Update --- docs/docs/agents/context.md | 50 +++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index bb2063e85..2d51271a7 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -1,40 +1,36 @@ # Context -**Context engineering** is the practice of building dynamic systems that provide the right information and tools, in the right format, so that a language model can plausibly accomplish a task. +**Context engineering** is the [art and science of filling the context window with just the right information](https://x.com/karpathy/status/1937902205765607626) so that an AI application can accomplish a task. Context can be characterized along two key dimensions: -Context includes *any* data outside the message list that can shape behavior. This can be: +**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) -- Information passed at runtime, like a `user_id` or API credentials. -- Internal state updated during a multi-step reasoning process. -- Persistent memory or facts from previous interactions. +**By lifetime:** +- **Runtime context**: Data scoped to a single run or invocation +- **Cross-conversation context**: Data that persists across multiple conversations or sessions -LangGraph provides **three** primary ways to manage context: +LangGraph provides three ways to manage context, combining the mutability and lifetime dimensions: -| Type | Description | Mutable? | Lifetime | -|------------------------------------------------------------------------------|-----------------------------------------------|----------|-------------------------| -| [**Runtime Context**](#runtime-context) | data passed at the start of a run | ❌ | per run | -| [**Short-term memory (State)**](#short-term-memory-mutable-context) | dynamic data that can change during execution | ✅ | per run or conversation | -| [**Long-term memory (Store)**](#long-term-memory-cross-conversation-context) | data that can be shared between conversations | ✅ | across conversations | +| Context Type | Description | Mutability | Lifetime | Access Method | +|------------------------------------------------------------------------------|--------------------------------------------------------|------------|-------------------------|-----------------------------------| +| [**Static Runtime Context**](#static-runtime-context) | User metadata, tools, db connections passed at startup | Static | Single run | `context` argument to `invoke`/`stream` | +| [**Dynamic Runtime Context (State)**](#dynamic-runtime-context-state) | Mutable data that evolves during a single run | Dynamic | Single run | LangGraph state object | +| [**Dynamic Cross-Conversation Context (Store)**](#dynamic-cross-conversation-context-store) | Persistent data shared across conversations | Dynamic | Cross-conversation | LangGraph store | -### Runtime Context +### Static Runtime Context -Runtime context is for immutable data like user metadata, tools, db connections, etc. Use this when you have values that don't change mid-run. +Static runtime context represents immutable data like user metadata, tools, and database connections that's passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data doesn't change during execution. !!! version-added "New in LangGraph v0.6: `Runtime.context` replaces `config['configurable']`" The `Runtime` object is recommended to access static context and runtime-specific information like the store and stream writer. -!!! note +!!! note "Application configuration vs. LLM Context" - 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. - - You likely want to use the local context to optimize the LLM's context window. For example, you - could use a user id to fetch a user's name and information from a database to populate the context window with relevant memories. - -Specify static context via the `context` argument to `invoke` / `stream`, which is reserved for this purpose: + Runtime context can include data that will be passed to the LLM (e.g., system prompt, tools) as well as application configuration (e.g., model settings, temperature, API keys, database connections) that governs application behavior but is not explicitly passed to the LLM. + +Application configuration can be passed via the `context` argument, which replaces `config['configurable']`. And, as before, any context you want to write to state for use in the application can be passed directly as a dictionary to `invoke` / `stream`. ```python @dataclass @@ -112,9 +108,9 @@ graph.invoke( # (1)! See the [tool calling guide](../how-tos/tool-calling.md#configuration) for details. -### Short-term memory (mutable context) +### Dynamic Runtime Context (State) -State acts as [short-term memory](../concepts/memory.md) during a run. It holds dynamic data that can evolve during execution, such as values derived from tools or LLM outputs. +**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](../concepts/memory.md) during a run. It holds dynamic data that can evolve during execution, such as values derived from tools or LLM outputs. === "In an agent" @@ -194,8 +190,8 @@ State acts as [short-term memory](../concepts/memory.md) during a run. It holds Please see the [memory guide](../how-tos/memory/add-memory.md) 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. -### Long-term memory (cross-conversation context) +## Dynamic Cross-Conversation Context (Store) -For context that spans *across* conversations or sessions, LangGraph allows access to **long-term memory** via a `store`. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions). +**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. For context that spans *across* conversations or sessions, LangGraph allows access to **long-term memory** via a `store`. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions). For more information, see the [Memory guide](../how-tos/memory/add-memory.md). \ No newline at end of file From 89efd6e9153218a856870718c571d88cd06c4d2c Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Mon, 28 Jul 2025 18:50:37 -0400 Subject: [PATCH 02/10] formatting --- docs/docs/agents/context.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index 2d51271a7..85edd4ec2 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -3,10 +3,12 @@ **Context engineering** is the [art and science of filling the context window with just the right information](https://x.com/karpathy/status/1937902205765607626) so that an AI application can accomplish a task. Context can be characterized along two key dimensions: **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 From 70185d350e49d1b0d9989ded37cc51dfa4e04f59 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Mon, 28 Jul 2025 19:02:47 -0400 Subject: [PATCH 03/10] adding xlinks --- docs/docs/agents/context.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index 85edd4ec2..88401b9be 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -20,7 +20,7 @@ LangGraph provides three ways to manage context, combining the mutability and li | [**Dynamic Runtime Context (State)**](#dynamic-runtime-context-state) | Mutable data that evolves during a single run | Dynamic | Single run | LangGraph state object | | [**Dynamic Cross-Conversation Context (Store)**](#dynamic-cross-conversation-context-store) | Persistent data shared across conversations | Dynamic | Cross-conversation | LangGraph store | -### Static Runtime Context +## Static Runtime Context Static runtime context represents immutable data like user metadata, tools, and database connections that's passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data doesn't change during execution. @@ -110,9 +110,9 @@ graph.invoke( # (1)! See the [tool calling guide](../how-tos/tool-calling.md#configuration) for details. -### Dynamic Runtime Context (State) +## Dynamic Runtime Context (State) -**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](../concepts/memory.md) during a run. It holds dynamic data that can evolve during execution, such as values derived from tools or LLM outputs. +**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](../concepts/memory.md) during a run. === "In an agent" @@ -194,6 +194,6 @@ graph.invoke( # (1)! ## Dynamic Cross-Conversation Context (Store) -**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. For context that spans *across* conversations or sessions, LangGraph allows access to **long-term memory** via a `store`. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions). +**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**](../concepts/memory.md#long-term-memory) across multiple runs. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions). For more information, see the [Memory guide](../how-tos/memory/add-memory.md). \ No newline at end of file From 4d80f4b1a5d21779d0bab8e007f108eef66d2802 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Mon, 28 Jul 2025 19:11:30 -0400 Subject: [PATCH 04/10] a few more nits --- docs/docs/agents/context.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index 88401b9be..7ee676daf 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -22,11 +22,11 @@ LangGraph provides three ways to manage context, combining the mutability and li ## Static Runtime Context -Static runtime context represents immutable data like user metadata, tools, and database connections that's passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data doesn't change during execution. +**Static runtime context** represents immutable data like user metadata, tools, and database connections that's passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data doesn't change during execution. !!! version-added "New in LangGraph v0.6: `Runtime.context` replaces `config['configurable']`" - The `Runtime` object is recommended to access static context and runtime-specific information like the store and stream writer. + The `Runtime` object is recommended to access static context and other utilities like the active store and stream writer. !!! note "Application configuration vs. LLM Context" From fa43b4694a84d90c09dd7353cd7dd601a25d671f Mon Sep 17 00:00:00 2001 From: Lauren Hirata Singh Date: Tue, 29 Jul 2025 07:03:12 -0400 Subject: [PATCH 05/10] Apply suggestions from code review --- docs/docs/agents/context.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index 7ee676daf..d4e12e01d 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -2,27 +2,27 @@ **Context engineering** is the [art and science of filling the context window with just the right information](https://x.com/karpathy/status/1937902205765607626) so that an AI application can accomplish a task. Context can be characterized along two key dimensions: -**By mutability:** +1. 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) + - **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:** +2. 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**: Data scoped to a single run or invocation + - **Cross-conversation context**: Data that persists across multiple conversations or sessions -LangGraph provides three ways to manage context, combining the mutability and lifetime dimensions: +LangGraph provides three ways to manage context, which combines the mutability and lifetime dimensions: -| Context Type | Description | Mutability | Lifetime | Access Method | +| Context type | Description | Mutability | Lifetime | Access method | |------------------------------------------------------------------------------|--------------------------------------------------------|------------|-------------------------|-----------------------------------| -| [**Static Runtime Context**](#static-runtime-context) | User metadata, tools, db connections passed at startup | Static | Single run | `context` argument to `invoke`/`stream` | -| [**Dynamic Runtime Context (State)**](#dynamic-runtime-context-state) | Mutable data that evolves during a single run | Dynamic | Single run | LangGraph state object | -| [**Dynamic Cross-Conversation Context (Store)**](#dynamic-cross-conversation-context-store) | Persistent data shared across conversations | Dynamic | Cross-conversation | LangGraph store | +| [**Static runtime context**](#static-runtime-context) | User metadata, tools, db connections passed at startup | Static | Single run | `context` argument to `invoke`/`stream` | +| [**Dynamic runtime context (state)**](#dynamic-runtime-context-state) | Mutable data that evolves during a single run | Dynamic | Single run | LangGraph state object | +| [**Dynamic cross-conversation context (store)**](#dynamic-cross-conversation-context-store) | Persistent data shared across conversations | Dynamic | Cross-conversation | LangGraph store | -## Static Runtime Context +## Static runtime context -**Static runtime context** represents immutable data like user metadata, tools, and database connections that's passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data doesn't change during execution. +**Static runtime context** represents immutable data like user metadata, tools, and database connections that are passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data does not change during execution. !!! version-added "New in LangGraph v0.6: `Runtime.context` replaces `config['configurable']`" @@ -110,7 +110,7 @@ graph.invoke( # (1)! See the [tool calling guide](../how-tos/tool-calling.md#configuration) for details. -## Dynamic Runtime Context (State) +## Dynamic runtime context (state) **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](../concepts/memory.md) during a run. @@ -192,8 +192,8 @@ graph.invoke( # (1)! Please see the [memory guide](../how-tos/memory/add-memory.md) 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. -## Dynamic Cross-Conversation Context (Store) +## Dynamic cross-conversation context (store) -**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**](../concepts/memory.md#long-term-memory) across multiple runs. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions). +**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](../concepts/memory.md#long-term-memory) across multiple runs. This can be used to read or update persistent facts (e.g., user profiles, preferences, prior interactions). For more information, see the [Memory guide](../how-tos/memory/add-memory.md). \ No newline at end of file From 4910830efe0635c582adb2880d2cbee78fef0b29 Mon Sep 17 00:00:00 2001 From: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com> Date: Tue, 29 Jul 2025 10:04:49 -0400 Subject: [PATCH 06/10] Apply suggestions from code review Co-authored-by: Lauren Hirata Singh --- docs/docs/agents/context.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index d4e12e01d..7bb35f39e 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -1,6 +1,6 @@ # Context -**Context engineering** is the [art and science of filling the context window with just the right information](https://x.com/karpathy/status/1937902205765607626) so that an AI application can accomplish a task. Context can be characterized along two key dimensions: +**Context engineering** is the practice of building dynamic systems that provide the right information and tools, in the right format, so that an AI application can accomplish a task. Context can be characterized along two key dimensions: 1. By **mutability**: @@ -32,7 +32,7 @@ LangGraph provides three ways to manage context, which combines the mutability a Runtime context can include data that will be passed to the LLM (e.g., system prompt, tools) as well as application configuration (e.g., model settings, temperature, API keys, database connections) that governs application behavior but is not explicitly passed to the LLM. -Application configuration can be passed via the `context` argument, which replaces `config['configurable']`. And, as before, any context you want to write to state for use in the application can be passed directly as a dictionary to `invoke` / `stream`. +Use the `Runtime` object to access static context and other utilities like the active store and stream writer. Any context you want to write to state for application use can be passed directly as a dictionary to `invoke` / `stream`. ```python @dataclass From 229727186315b06aa2701ce09e7d05c61b323311 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Tue, 29 Jul 2025 10:19:48 -0400 Subject: [PATCH 07/10] refining tips --- docs/docs/agents/context.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index 7bb35f39e..fa02a239e 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -24,15 +24,20 @@ LangGraph provides three ways to manage context, which combines the mutability a **Static runtime context** represents immutable data like user metadata, tools, and database connections that are passed to an application at the start of a run via the `context` argument to `invoke`/`stream`. This data does not change during execution. -!!! version-added "New in LangGraph v0.6: `Runtime.context` replaces `config['configurable']`" +!!! version-added "New in LangGraph v0.6: `context` replaces `config['configurable']`" - The `Runtime` object is recommended to access static context and other utilities like the active store and stream writer. + Runtime context should be passed to the `context` argument of `invoke`/`stream`. + This replaces the previous pattern of passing application configuration to `config['configurable']`. -!!! note "Application configuration vs. LLM Context" +!!! tip "Runtime context vs LLM context" - Runtime context can include data that will be passed to the LLM (e.g., system prompt, tools) as well as application configuration (e.g., model settings, temperature, API keys, database connections) that governs application behavior but is not explicitly passed to the LLM. - -Use the `Runtime` object to access static context and other utilities like the active store and stream writer. Any context you want to write to state for application use can be passed directly as a dictionary to `invoke` / `stream`. + 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. + + Runtime context can be **used to** optimize the LLM context. For example, you can use user metadata + in the runtime context to fetch user preferences and feed them into the context window. ```python @dataclass @@ -110,6 +115,11 @@ graph.invoke( # (1)! See the [tool calling guide](../how-tos/tool-calling.md#configuration) for details. +!!! tip "Using the `Runtime` object in nodes and tools" + + The `Runtime` object can be used to access static context and other utilities like the active store and stream writer. + See the [Runtime][langgraph.runtime.Runtime] documentation for details. + ## Dynamic runtime context (state) **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](../concepts/memory.md) during a run. From 474fb7b33ee70d018b159d806a89aeff0c9539f3 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Tue, 29 Jul 2025 10:22:50 -0400 Subject: [PATCH 08/10] consolidate --- docs/docs/agents/context.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index fa02a239e..c11be7797 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -26,8 +26,8 @@ LangGraph provides three ways to manage context, which combines the mutability a !!! version-added "New in LangGraph v0.6: `context` replaces `config['configurable']`" - Runtime context should be passed to the `context` argument of `invoke`/`stream`. - This replaces the previous pattern of passing application configuration to `config['configurable']`. + Runtime context is now passed to the `context` argument of `invoke`/`stream`, + which replaces the previous pattern of passing application configuration to `config['configurable']`. !!! tip "Runtime context vs LLM context" @@ -115,7 +115,7 @@ graph.invoke( # (1)! See the [tool calling guide](../how-tos/tool-calling.md#configuration) for details. -!!! tip "Using the `Runtime` object in nodes and tools" +!!! tip The `Runtime` object can be used to access static context and other utilities like the active store and stream writer. See the [Runtime][langgraph.runtime.Runtime] documentation for details. From 469ebd34925099cb22622c6b655c6f4670d0148c Mon Sep 17 00:00:00 2001 From: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com> Date: Tue, 29 Jul 2025 10:58:59 -0400 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Lauren Hirata Singh --- docs/docs/agents/context.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index c11be7797..2fa2bd488 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -31,12 +31,12 @@ LangGraph provides three ways to manage context, which combines the mutability a !!! tip "Runtime context vs LLM context" - Runtime context refers to local context: data and dependencies your code needs to run. It does not refer to: + 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. - Runtime context can be **used to** optimize the LLM context. For example, you can use user metadata + Runtime context can be used to optimize the LLM context. For example, you can use user metadata in the runtime context to fetch user preferences and feed them into the context window. ```python From fdfd06056e369987cd269efc9432145944734615 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Tue, 29 Jul 2025 11:00:40 -0400 Subject: [PATCH 10/10] move tip --- docs/docs/agents/context.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/docs/agents/context.md b/docs/docs/agents/context.md index 2fa2bd488..d8db38c49 100644 --- a/docs/docs/agents/context.md +++ b/docs/docs/agents/context.md @@ -12,6 +12,16 @@ - **Runtime context**: Data scoped to a single run or invocation - **Cross-conversation context**: Data that persists across multiple conversations or sessions +!!! tip "Runtime context vs LLM context" + + 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. + + Runtime context can be used to optimize the LLM context. For example, you can use user metadata + in the runtime context to fetch user preferences and feed them into the context window. + LangGraph provides three ways to manage context, which combines the mutability and lifetime dimensions: | Context type | Description | Mutability | Lifetime | Access method | @@ -29,16 +39,6 @@ LangGraph provides three ways to manage context, which combines the mutability a Runtime context is now passed to the `context` argument of `invoke`/`stream`, which replaces the previous pattern of passing application configuration to `config['configurable']`. -!!! tip "Runtime context vs LLM context" - - 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. - - Runtime context can be used to optimize the LLM context. For example, you can use user metadata - in the runtime context to fetch user preferences and feed them into the context window. - ```python @dataclass class ContextSchema: