fix(langgraph): key error on runtime for config w/o configurable (#6106)

Fixes https://github.com/langchain-ai/langgraph/issues/6072

Long term we probably want a more robust approach to configurable
management in terms of required / not required attributes.
This commit is contained in:
Sydney Runkle
2025-09-10 12:19:33 +00:00
committed by GitHub
parent 6037f0210f
commit 326fd55e4f
2 changed files with 20 additions and 2 deletions
@@ -345,7 +345,7 @@ class RunnableCallable(Runnable):
args = (input,)
kwargs = {**self.kwargs, **kwargs}
runtime = config[CONF].get(CONFIG_KEY_RUNTIME)
runtime = config.get(CONF, {}).get(CONFIG_KEY_RUNTIME)
for kw, (runtime_key, default) in self.func_accepts.items():
# If the kwarg is already set, use the set value
@@ -417,7 +417,7 @@ class RunnableCallable(Runnable):
args = (input,)
kwargs = {**self.kwargs, **kwargs}
runtime = config[CONF].get(CONFIG_KEY_RUNTIME)
runtime = config.get(CONF, {}).get(CONFIG_KEY_RUNTIME)
for kw, (runtime_key, default) in self.func_accepts.items():
# If the kwarg has already been set, use the set value
+18
View File
@@ -394,3 +394,21 @@ def test_config_injection() -> None:
assert RunnableCallable(func_untyped).invoke(
"test", config={"tags": ["test"], "configurable": {}}
) == ["test"]
def test_config_ensured() -> None:
def func(input: str, config: RunnableConfig) -> None:
assert input == "test"
assert config is not None
assert config.get("configurable") is not None
RunnableCallable(func).invoke("test")
async def test_config_ensured_async() -> None:
async def func(input: str, config: RunnableConfig) -> None:
assert input == "test"
assert config is not None
assert config.get("configurable") is not None
await RunnableCallable(func).ainvoke("test")