Skip to content

The agent engineering platform.

fix(core): exclude api_key from tracing metadata (#32184)

ccurmeebf2e11bcbf3
diff --git a/libs/core/langchain_core/runnables/config.py b/libs/core/langchain_core/runnables/config.py
index f1bf2f6500..4ac7bda7b4 100644
--- a/libs/core/langchain_core/runnables/config.py
+++ b/libs/core/langchain_core/runnables/config.py
@@ -230,6 +230,7 @@ def ensure_config(config: Optional[RunnableConfig] = None) -> RunnableConfig:
not key.startswith("__")
and isinstance(value, (str, int, float, bool))
and key not in empty["metadata"]
+ and key != "api_key"
):
empty["metadata"][key] = value
return empty