Skip to content

The agent engineering platform.

RunnableWithMessageHistory: Fix input schema (#14516)

Eugene Yurtsevc0f4b95aa996
diff --git a/libs/core/langchain_core/runnables/history.py b/libs/core/langchain_core/runnables/history.py
index 98c6b1a091..e0bb9281ff 100644
--- a/libs/core/langchain_core/runnables/history.py
+++ b/libs/core/langchain_core/runnables/history.py
@@ -197,8 +197,6 @@ class RunnableWithMessageHistory(RunnableBindingBase):
fields[self.input_messages_key] = (Sequence[BaseMessage], ...)
else:
fields["__root__"] = (Sequence[BaseMessage], ...)
- if self.history_messages_key:
- fields[self.history_messages_key] = (Sequence[BaseMessage], ...)
return create_model( # type: ignore[call-overload]
"RunnableWithChatHistoryInput",
**fields,
diff --git a/libs/core/tests/unit_tests/runnables/test_history.py b/libs/core/tests/unit_tests/runnables/test_history.py
index c5f02c9313..49f68825ba 100644
--- a/libs/core/tests/unit_tests/runnables/test_history.py
+++ b/libs/core/tests/unit_tests/runnables/test_history.py
@@ -178,7 +178,6 @@ def test_output_dict() -> None:
def test_get_input_schema_input_dict() -> None:
class RunnableWithChatHistoryInput(BaseModel):
input: Union[str, BaseMessage, Sequence[BaseMessage]]
- history: Sequence[BaseMessage]
runnable = RunnableLambda(
lambda input: {