Skip to content

The agent engineering platform.

Fix condition on custom root type in runnable history (#17017)

Nuno Camposae56fd020a78
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 = {}