-
Notifications
You must be signed in to change notification settings - Fork 190
Support multiple system messages for Anthropic #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Support multiple system messages for Anthropic #572
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelnchin
Thanks for submitting this change.
After looking at the langchain-anthropic integration, I am not convinced if it allows system messages to be present anywhere in the message sequence. While the logic to allow merging of consecutive system messages at the beginning seems valid, the actual change here seems to extract system messages that might be non-consecutive, which will conflict with anthropic's expectations.
Can you request the issue reporter to provide a small sample case to test against and make sure we can validate that with anthropic's native integration?
One note, this PR's changes mirrors those made a previous PR for langchain-anthropic: langchain-ai/langchain#27725 In both implementations, non-consecutive system messages are indeed initially extracted by I've added an extra test case to verify that we properly throw an error in such cases. |
Hi! I was facing the same issue described in #498 and can confirm that @michaelnchin changes work. Here's a minimal example that was failing before but works with these changes:
When summarization triggers, it creates multiple system messages that violate the "system message must be at beginning" validation. Happy to provide more details if needed! |
Addresses #498 for ChatBedrock.