trim_messages
causes an IndexError when invoked with strategy="last"
, include_system=True
, and empty messages
#26895
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
Ɑ: core
Related to langchain-core
investigate
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Error type:
IndexError
Stack trace:
Description
What is the issue?
trim_messages
withinclude_system=True
in aRunnableWithMessageHistory
without a message already in a MessageHistoryExpected behaviour:
Current behaviour:
IndexError
and crashesThis was found when setting up a
RunnableWithMessageHistory
where there were no initial messages in the store to pull from.The documentation currently provides examples where prior messages are available, which could be a pitfall to new users.
Testing
I have tested all other combinations of argument values for:
strategy
allow_partials
include_system
starts_on
(partially with only "human" and "system")ends_on
(partially with only "human" and "system")The error is only triggered when
strategy="last"
andinclude_system=True
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: