Revert "chore: update configurable metadata" (#7393)

Reverts langchain-ai/langgraph#7367
This commit is contained in:
William FH
2026-04-02 11:05:17 -07:00
committed by GitHub
parent b3eeb4fa1d
commit 9f5f3fb35e
2 changed files with 20 additions and 2 deletions
+19 -1
View File
@@ -1,7 +1,7 @@
from __future__ import annotations
from collections import ChainMap
from collections.abc import Sequence
from collections.abc import Mapping, Sequence
from os import getenv
from typing import Any, cast
@@ -308,4 +308,22 @@ def ensure_config(*configs: RunnableConfig | None) -> RunnableConfig:
for k, v in config.items():
if _is_not_empty(v) and k not in CONFIG_KEYS:
empty[CONF][k] = v
_empty_metadata = empty["metadata"]
for key, value in empty[CONF].items():
if _exclude_as_metadata(key, value, _empty_metadata):
continue
_empty_metadata[key] = value
return empty
_OMIT = ("key", "token", "secret", "password", "auth")
def _exclude_as_metadata(key: str, value: Any, metadata: Mapping[str, Any]) -> bool:
key_lower = key.casefold()
return (
key.startswith("__")
or not isinstance(value, (str, int, float, bool))
or key in metadata
or any(substr in key_lower for substr in _OMIT)
)
+1 -1
View File
@@ -312,7 +312,7 @@ def test_configurable_metadata():
},
"metadata": {"nooverride": 18},
}
expected = {"nooverride"}
expected = {"includeme", "andme", "nooverride"}
merged = ensure_config(config)
metadata = merged["metadata"]
assert metadata.keys() == expected