1111
1212from langchain_core .runnables import Runnable , RunnableConfig
1313from langchain_core .runnables .config import var_child_runnable_config
14+ from langgraph ._internal ._constants import CONFIG_KEY_RUNTIME
1415from langgraph .config import get_config
15- from langgraph .constants import CONF , CONFIG_KEY_STORE
16+ from langgraph .constants import CONF
17+ from langgraph .runtime import Runtime
1618from langgraph .store .base import BaseStore
1719from langgraph_sdk import get_client , get_sync_client
1820from langsmith .utils import ContextThreadPoolExecutor
@@ -294,7 +296,9 @@ def submit(
294296 with self ._store_lock :
295297 if self ._store is None :
296298 try :
297- self ._store = config [CONF ][CONFIG_KEY_STORE ]
299+ existing_store = config [CONF ][CONFIG_KEY_RUNTIME ].store
300+ if existing_store is None :
301+ raise KeyError ()
298302 except KeyError :
299303 raise ValueError (
300304 "ReflectionExecutor could not resolve store to persist memories to."
@@ -421,7 +425,13 @@ def _process_queue(self: "LocalReflectionExecutor"):
421425 try :
422426 config = task .config or {}
423427 configurable = config .setdefault (CONF , {})
424- configurable [CONFIG_KEY_STORE ] = self ._store
428+ if (runtime := configurable .get (CONFIG_KEY_RUNTIME )) is None :
429+ patched_runtime = Runtime (store = self ._store )
430+ else :
431+ patched_runtime = typing .cast (Runtime , runtime ).override (
432+ store = self ._store
433+ )
434+ configurable [CONFIG_KEY_RUNTIME ] = patched_runtime
425435 original = var_child_runnable_config .set (config )
426436 result = self ._reflector .invoke (task .payload )
427437 var_child_runnable_config .set (original .old_value )
@@ -444,7 +454,13 @@ def _process_queue(self: "LocalReflectionExecutor"):
444454 try :
445455 config = task .config or {}
446456 configurable = config .setdefault (CONF , {})
447- configurable [CONFIG_KEY_STORE ] = self ._store
457+ if (runtime := configurable .get (CONFIG_KEY_RUNTIME )) is None :
458+ patched_runtime = Runtime (store = self ._store )
459+ else :
460+ patched_runtime = typing .cast (Runtime , runtime ).override (
461+ store = self ._store
462+ )
463+ configurable [CONFIG_KEY_RUNTIME ] = patched_runtime
448464 original = var_child_runnable_config .set (config )
449465 result = self ._reflector .invoke (task .payload )
450466 var_child_runnable_config .set (original .old_value )
0 commit comments