mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-09 11:17:53 +02:00
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:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user