From ae56fd020a780bc70f5d4b8582a025903a6db0f5 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Mon, 5 Feb 2024 12:15:11 -0800 Subject: [PATCH] Fix condition on custom root type in runnable history (#17017) --- libs/core/langchain_core/runnables/history.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/core/langchain_core/runnables/history.py b/libs/core/langchain_core/runnables/history.py index bd72e40538..f83de39cee 100644 --- a/libs/core/langchain_core/runnables/history.py +++ b/libs/core/langchain_core/runnables/history.py @@ -341,7 +341,9 @@ class RunnableWithMessageHistory(RunnableBindingBase): self, config: Optional[RunnableConfig] = None ) -> Type[BaseModel]: super_schema = super().get_input_schema(config) - if super_schema.__custom_root_type__ is not None: + if super_schema.__custom_root_type__ or not super_schema.schema().get( + "properties" + ): from langchain_core.messages import BaseMessage fields: Dict = {}