Skip to content
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

fix ChatSummaryMemoryBuffer._summarize_oldest_chat_history #17845

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pablonm3
Copy link

@pablonm3 pablonm3 commented Feb 17, 2025

Description

ChatSummaryMemoryBuffer._summarize_oldest_chat_history is crashing due to sending a single message with role system while Anthropic expects also a user message. Also current implementation is missing the instruction to summarize (summarize_prompt) which I added as role: system and moved context to next message as role: user

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 17, 2025
role=MessageRole.SYSTEM,
content=self.summarize_prompt,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so self.summarize_prompt is already included when you run self._get_prompt_to_summarize(..) (check the end of that function)

Maybe the only change we needed here changing the summarize prompt to the user role?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response @logan-markewich
what do you think about my last commit to this branch where I remove the prompt += self.summarize_prompt or "" from _get_prompt_to_summarize ? this way we send the instruction as system role and the context as user role which IMO is better than sending both as user role. also IMO it's better to put the instruction before the context rather than after. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants